JDD/Driver Locale

From J Wiki
< JDD
Jump to navigation Jump to search
JDD: Driver Locale | Handles | Data Sources | Data Driver | Error Messages | API: Connect Read Update Create Bulk Insert

Driver

JDD is only an abstract interface specification, concrete implementation is provided by various drivers written in J. Since it is written in J with C API calls, most likely both Linux and Windows are supported.

Currently, drivers for SQLite and MySQL have been implemented.

Driver Locale

Each driver is contained in its own class definition, so that its class definition has to be loaded first,

NB. file for each JDD driver will be placed under the folder ~addons/data
load 'data/ddmysql'

this will load a class 'jddmysql', verbs can be accessed with fully qualified names such as ddcon_jddmysql_. However some initialization is required before use and it it more convenient to create an object (numbered locale) from it.

NB. note the dyad conew will call the verb 'create' to do initialization.
db=. '' conew 'jddmysql'

Subsequently, verbs inside locale db will be used.

ch=. ddcon__db '......'

   a lot of codes here

dddis__db ch

Finally, remember to cleanup locale

destroy__db''

This is the recommended way to use JDD in writing new codes.

z locale

In order to make migration from J/ODBC easier, verbs in JDD can also be exported to z locale with the verb setzlocale

The general pattern looks like this,

load 'data/ddmysql'

setzlocale_jddmysql_ ''

ch=. ddcon '......'

   a lot of codes here

dddis ch

While this method have advantages such as,

  • can run un-modified codes written for J/ODBC
  • less typing in an interactive session

Disadvantages include,

  • conflicts with J/ODBC
  • different JDD drivers can not be used simultaneously