Database

Parameters

 opts - (optional) equations of the form option=string where option is one of driver or classpath

Description

 • The LoadDriver command attempts to load a Java Database Connectivity [JDBC] driver, which Maple uses to connect to a database.  With no arguments, Maple tries to load a driver from a list of known drivers.  It uses the current value of the CLASSPATH environment variable as the search path for the Driver. If no JDBC driver can be loaded, then an exception is raised.  For more information about JDBC drivers, see JDBC.
 • The LoadDriver command returns a Driver module.  The OpenConnection export of this module can be used to connect to the database.  For an overview of using the Database package, see usage.
 • The LoadDriver command accepts two optional parameters that specify which driver to use.
 driver = string
 Specify the package name of the Java Driver class to use.  This name must be available in the documentation for the JDBC driver being used.  It must be similar in form to "com.vendorname.Driver".  If a classpath argument is not specified it looks for this class using the CLASSPATH environment variable.
 classpath = string
 Specify locations to search for the JDBC Driver.  The string must contain directories and .jar files in the same format as is used for the CLASSPATH variable.  That is, paths delimited by kernelopts( pathsep ), where a directory path indicates to search .class file within that directory and a .jar file indicates to search .class files within that .jar file.  Most JDBC drivers are shipped in the form of a .jar file.  For example classpath="database/java/jdbc.jar".  If you do not specify a driver argument then Maple attempts to load a Driver from a list of known drivers.
 • The list of known drivers used by LoadDriver is, com.mysql.jdbc.Driver (for MySQL databases), org.postgresql.Driver (for PostgreSQL databases), net.sourceforge.jtds.jdbc.Driver (for Microsoft SQL Server databases) and com.sybase.jdbc2.jdbc.SybDriver (for various Sybase databases).  When no driver argument is given, Maple stops searching after the first Driver is successfully loaded.  Therefore, specifying driver or classpath may be required if multiple JDBC drivers are installed.

Examples

Let Maple look for the driver.

 > $\mathrm{driver}≔\mathrm{Database}\left[\mathrm{LoadDriver}\right]\left(\right)$

No valid driver found.  Try specifying the classpath.

 > $\mathrm{driver}≔\mathrm{Database}\left[\mathrm{LoadDriver}\right]\left('\mathrm{classpath}'="c:\\database\\jdbc\\driver.jar"\right)$

 > $\mathrm{driver}≔\mathrm{Database}\left[\mathrm{LoadDriver}\right]\left('\mathrm{driver}'="com.jdbc.Driver"\right)$
 > $\mathrm{driver}≔\mathrm{Database}\left[\mathrm{LoadDriver}\right]\left('\mathrm{driver}'="com.jdbc.Driver",'\mathrm{classpath}'="c:\\database\\jdbc\\driver.jar"\right)$
 ${\mathrm{driver}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{unload}}{=}{\mathrm{Close}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{handle}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{OpenConnection}}{,}{\mathrm{Close}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (1)