Oracle Lite and Java javacode 9085791

Oracle Lite and Java

Oracle lite is a very interesting product. As the name indicates, is it a lite version of the Oracle database and thus capable of running on a PDA, laptop and (soon) mobile phone. One of its main features are the synchronization capabilities with a master Oracle database. A special SQL+ client is also available: MSQL. In the windows environment (e.g. on a laptop with Windows XP) the actual connection with the Oracle lite database uses ODBC (I am curious how this is done in a Linux environment). This means that for Java applications a special JDBC driver, actually a JDBC ODBC bridge, is needed which is provided with olite40.jar and can be found (multiple times, but fortunately all with the same size) in the Oracle lite install directory.

package nl.amis.demo.olite;
import java.sql.*;
public class OliteApp {
    public void performQuery() {
        try
        {
            Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
            Connection conn = DriverManager.getConnection
("jdbc:polite:ODBC_dsn", "system", "userpwd");
            PreparedStatement pstmt = conn.prepareStatement("select * from emp");
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getString("ENAME"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        OliteApp oliteApp = new OliteApp();
        oliteApp.performQuery();
    }
}

As you can see, the code is no different from any other JDBC code. The only weird thing is that you have to connect with the system user, but you need to provide the user’s password (see this OTN Oracle lite post), b.t.w. this is also the case for mSQL.

5 Comments

  1. Raghu July 16, 2009
  2. sansaniwal (india) February 17, 2006
  3. Ruth Fabiola Palomino February 16, 2006
  4. rekounas October 27, 2005
  5. rekounas October 27, 2005