|
|
Introduction
Mimer JDBC Drivers provide access to Mimer SQL databases from Java applications and applets. The drivers are type 4 drivers, which means that they are written entirely in Java. As they are written in Java, they can be downloaded in applets.
Mimer JDBC Drivers can also be used on all platforms that support Java Virtual Machine (JVM) and so provide a very high degree of portability.
About this Guide
The guide is intended for Java application developers working with Mimer SQL. It covers all available Mimer JDBC drivers.
The guide describes the usage of SQL in Java applications, and provides, together with the Mimer SQL Reference Manual, the complete reference material for Mimer SQL.
To read more about JDBC and JVM, visit http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136101.html.
The JDBC API specification implemented by this driver (packages java.sql and javax.sql) is found at http://download.oracle.com/javase/1.4.2/docs/api/java/sql/package-summary.html and http://download.oracle.com/javase/1.4.2/docs/api/javax/sql/package-summary.html.
Definitions, Terms and Trademarks
All other trademarks are the property of their respective holders.
Available Drivers
At the moment, the following Mimer JDBC drivers are available:
- mimjdbc3.jar supports the JDBC 3 specification and is J2EE compliant. This is currently the main JDBC driver, which should be used in most situations. This driver requires a Java 1.4 runtime or later.
- mimjdbc1.jar and mimjdbc2.jar supports the JDBC 1.2 and JDBC 2 specifications respectively. These drivers support the same server features as mimjdbc3.jar, but are supposed to be used on platforms and in environments where modern Java runtime environments are not supported. mimjdbc2.jar is J2EE compliant.
- minjdbc3.jar supports the JDBC Optional Package for CDC/Foundation Profile specification and is J2ME compliant. This driver supports a subset of the JDBC 3 specification and is aimed at devices with limited memory resources. See further down in this document for specifics on what is supported and not.
- midjdbc2.jar implements a subset of the functionality provided by the minjdbc3 driver. It is J2ME compliant and is supposed to be used in environments supporting the CLDC/Mobile Information Device Profile specification. See further down in this document for specifics on what is supported and not.
Requirements
Environment
Mimer JDBC has a complete range of functionality and support for the smallest devices to the high-end systems and application servers. In the picture below the various Java environments are described and coupled with computer environments and Mimer JDBC drivers:
In addition, the mimjdbc1 and mimjdbc2 drivers are available for older environments (see Available Drivers).
Differences Between the Drivers
In most cases the mimjdbc3 driver should be used. The mimjdbc1 and mimjdbc2 drivers should be used when only older Java runtime environments are supported. The minjdbc3 and midjdbc2 drivers are mainly for smaller and resource constrained environments.
The following table lists differences between the drivers:
Note: A requirement for functionality support regarding to the table above is that the database server version used is supporting the functionality.
The default fetch size for the mimjdbc drivers is about 64 kB. In the minjdbc and midjdbc drivers the buffer size is 10 kB. This buffer size can be manipulated using the .setFetchSize method.
About the JDBC Driver for J2ME/CDC (minjdbc3)
The Mimer JDBC driver for J2ME/CDC uses less memory resources than the regular drivers. The code size itself has been reduced by removing features not included in the JDBC for J2ME/CDC specification. Furthermore the J2ME-driver allocates smaller buffers for network packets and internal data.
The Mimer JDBC driver for J2ME/CDC is primarily intended to be used on a device with limited memory resources. It can connect to any type of Mimer SQL server.
About the JDBC Driver for Midlets (midjdbc3)
The Mimer MIDP driver should be used in environments supporting the CLDC/MID Profile specification. It is a strict subset of the regular JDBC for CDC configurations API. Also applications developed with Mimer MIDP will run with little change in a regular JDBC environment and vice versa. Programming skills obtained using regular JDBC programming may be applied to programming within the MIDP environment as well.
The following features are omitted in the Mimer JDBC for MIDP:
- All methods requiring floating point data types (such as ResultSet.getDouble). See below on floats, doubles and BigDecimal's for guidelines on handling these cases.
- All methods requiring a java.sql.Date, java.sql.Time and java.sql.Timestamp data type. When working with SQL date, time and timestamp data, please consider using ResultSet.getString, PreparedStatement.setString and other string getter and setter methods instead.
- The MIDP driver has no finalize() methods. This means that it is even more important for applications to explicitly close database objects when done with them.
- Since the java.math library is omitted from MIDP, no BigDecimal's may be used. Please consider using the appropriate java.lang.String getter or setter method.
- There is no java.sql interface. Programs interact directly against the com.mimer.jdbc classes instead. See below for a list of corresponding classes. Basically, instead of importing java.sql.*, you should import com.mimer.jdbc.* instead and carry on as usual.
Importing the JDBC Classes
Because the K Virtual Machine per default does not allow loading system class (java.*) applications accessing Mimer SQL databases should import the com.mimer.jdbc.* classes instead. This makes the application less portable than a regular JDBC application, but these are the constraints set by the environment.
The following Mimer classes correspond to the named interface classes in the regular JDBC API.
See also the javadoc for the Mimer MIDP driver. It is available on the Mimer SQL Developer site: http://developer.mimer.com/documentation/latest_javadoc_midp/index.html.
FLOAT and DOUBLE PRECISION
Databases with FLOAT, DOUBLE PRECISION, REAL and INTEGER(n) columns which are required to expose these numbers in a MIDlet can use one the following tricks to go around the float and BigDecimal limitation in the K Virtual Machine.
- It is always possible to get the SQL FLOAT or DOUBLE PRECISION value into a java.lang.String. This will work particularly well if the data is only to be displayed.
- To handle fractions so that they may be used to some calculations, make sure at the SQL level to always return integers and reserving the last digits of the integer for decimals. If the database has a FLOAT column and we are interested in 4 decimals, do the following SQL:
select cast(OUR_FLOAT*10000 as bigint) from OUR_TABLE
- At the application level, place the result in an int or a long, but assume that the last 4 digits are decimals when displaying values to the user. In addition, decimals entered by the user must be handled similarly by the application before being inserted to the database. The following SQL statement may be used to make the float appear correctly in a table.
insert into OUR_TAB(OUR_FLOAT) values (cast(? as float)/10000);DATE, TIME and TIMESTAMP
DATE, TIME and TIMESTAMP system classes (java.util.Date) are not included in the MIDP specification. Therefore the Mimer client cannot return DATE, TIME or TIMESTAMP objects. Please use string getter and setter methods instead.
Logging
To keep the driver size small and to optimize performance the Mimer JDBC drivers do not perform any logging. For logging, we provide a separate driver, Mimer JDBC Trace driver.
Mimer JDBC Trace driver is a full JDBC Driver that covers all of JDBC by calling the matching routines of the logged JDBC Driver.
It produces a log of every JDBC call an application makes, and also measures the elapsed time for each call. The log can be written to a file, or can be displayed directly in a window.
For more information, see http://developer.mimer.com/howto/howto_28.htm.
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|