Project

General

Profile

About

This is a plugin to connect to any JDBC datasource directly from within code, and bypasses Servoy's default connection handling and pooling. This is useful for several situations:
  • Using drivers that aren't fully Type-4 compliant. Servoy requires a lot of metadata from the drivers, which many don't support.
  • Creating connection on-the-fly
There are 3 functions you can use
  • setConnection(driverClass, JDBCUrl, username, password)
  • getDataSetByQuery(sql, args, maxReturnedRows)
  • getLastError()

How to Use

Here is an example connecting to FileMaker using my old JDBC driver for FMP here: https://sites.google.com/site/goldcougar83/home2
We get a connection to the DB, and write direct SQL and retrieve back a standard JSDataSet

var success = plugins.DirectSQL.setConnection("com.ddc.drivers.fmpxml.Driver", "jdbc:ddc://10.1.1.1/DBFileName?pk=idno", "admin", "mypass")
if(!success){
    application.output(plugins.DirectSQL.getLastError())
    return
}

var sql = 'SELECT * FROM tablename WHERE idno = ?'
var args = [1]
var ds = plugins.DirectSQL.getDataSetByQuery(sql, args, -1)
application.output(ds.getAsHTML())

Example Uses

  • Connecting to databases like FileMaker, Access, FoxPro DBF files that aren't fully type-4 compliant, or you need direct access to local files on the client's machien
  • Using drivers for reading special file types, like CSV: http://csvjdbc.sourceforge.net/

Deployment

In the download, place the directSQL.jar and directSQL.jar.jnlp in your application_server/plugins folder. Then create a subfolder called "DirectSQL". In that folder, place your dependent JDBC Drivers that you want to use (make sure they are signed). Finally, modify the directSQL.jar.jnlp file following the sample by adding a reference for each of your JDBC drivers. This makes sure they get downloaded to the client.