MySQL JDBC & RMI

I have been developing a project, in which I have a Remote Object(RMI) which returns a ResultSet object obtained by MySql JDBC(J-Connector).
The problem is the ResultSet object does not implement the Serializable Interface so that it cannot be passed to the client site from the remote site through RMI. This is fine, I have other way of solving this, except it will reduce my performance quite a lot!
Therefor, I am wondering how does MYSQL JDBC does this...
I can run a client in one machine and a DB (say MySQL)on the other machine. Using JDBC to connect them, and I can get the ResultSet with no problem at all, this resultset is also remote somehow. My question is how does MYSQL JDBC handle this, so that the data get passed from one mechine to another, and the speed is really fast....
An answer will be a great value to me. Thanks in advance...

JDBC connects to the Database not to a Java RMI server. You cannot pass a ReultSet around like this. They retain a connection to the Database (usually) until all rows have been and then still (usually) until closed. For this reason alone, it would be impossible to pass around ResultSets in this manner, and I am sure there are other reasons.

Similar Messages

  • Unable to create : com.mysql.jdbc.Driver error with JDeveloper 10.1.3

    Hi all,
    I got this error when I tried to execute a simple JSF app. I am using JDeveloper 10.1.3 release edition. Please advice
    [Starting OC4J using the following ports: HTTP=8988, RMI=23891, JMS=9227.]
    **** Unable to obtain password from principals.xml. Using default.
    C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\config>
    C:\JDeveloper10g\jdk\bin\javaw.exe -ojvm -classpath C:\JDeveloper10g\j2ee\home\oc4j.jar;C:\JDeveloper10g\jdev\lib\jdev-oc4j-embedded.jar -Xverify:none -DcheckForUpdates=adminClientOnly -Doracle.application.environment=development -Doracle.j2ee.dont.use.memory.archive=true -Doracle.j2ee.http.socket.timeout=500 -Doc4j.jms.usePersistenceLockFiles=false oracle.oc4j.loader.boot.BootStrap -config C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\config\server.xml
    [waiting for the server to complete its initialization...]
    2006-01-31 21:40:47.062 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war...
    2006-01-31 21:40:47.093 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms
    2006-01-31 21:40:47.093 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\dms.war
    2006-01-31 21:40:47.156 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar...
    2006-01-31 21:40:47.156 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources
    2006-01-31 21:40:47.171 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\connectors\datasources\datasources.rar
    2006-01-31 21:40:47.218 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear...
    2006-01-31 21:40:47.281 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j
    2006-01-31 21:40:47.359 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j.ear
    2006-01-31 21:40:47.375 NOTIFICATION Auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war...
    2006-01-31 21:40:47.375 NOTIFICATION Unjar C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war in C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp
    2006-01-31 21:40:59.296 NOTIFICATION Finished auto-unpacking C:\JDeveloper10g\jdev\system\oracle.j2ee.10.1.3.36.73\embedded-oc4j\applications\bc4j\webapp.war
    2006-01-31 21:41:08.421 WARNING J2EE OJR0107 Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    06/01/31 21:41:08 SEVERE: ApplicationStateRunning.initConnector Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    Jan 31, 2006 9:41:08 PM com.evermind.server.ApplicationStateRunning initConnector
    SEVERE: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    06/01/31 21:41:08 SEVERE: ApplicationStateRunning.initConnector Stack trace: oracle.oc4j.sql.DataSourceException: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2016)
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnector(ApplicationStateRunning.java:1961)
         at com.evermind.server.ApplicationStateRunning.initConnector(ApplicationStateRunning.java:1220)
         at com.evermind.server.ApplicationStateRunning.initConnectors(ApplicationStateRunning.java:356)
         at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:208)
         at com.evermind.server.Application.setConfig(Application.java:391)
         at com.evermind.server.Application.setConfig(Application.java:309)
         at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771)
         at com.evermind.server.ApplicationServer.initializeDeployedApplications(ApplicationServer.java:1532)
         at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:939)
         at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:113)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.resource.ResourceException: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:106)
         at oracle.oc4j.sql.DataSourceUtils.getDataSourceConnectionPool(DataSourceUtils.java:322)
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:1997)
         ... 11 more
    Caused by: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:247)
         at oracle.oc4j.sql.DataSourceConnectionPoolImpl.<init>(DataSourceConnectionPoolImpl.java:107)
         at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:99)
         ... 13 more
    Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
         Missing class: com.mysql.jdbc.Driver
         Dependent class: oracle.oc4j.sql.config.DataSourceConfigUtils
         Loader: oc4j:10.1.3
         Code-Source: /C:/JDeveloper10g/j2ee/home/lib/oc4j-internal.jar
         Configuration: <code-source> in META-INF/boot.xml in C:\JDeveloper10g\j2ee\home\oc4j.jar
    This load was initiated at current-workspace-app.root:0.0.0 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
         at oracle.classloader.PolicyClassLoader.handleClassNotFound(PolicyClassLoader.java:2061)
         at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1665)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1621)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1606)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:242)
         at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:244)
         ... 15 more
    Jan 31, 2006 9:41:08 PM com.evermind.server.ApplicationStateRunning initConnector
    SEVERE: Stack trace: oracle.oc4j.sql.DataSourceException: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2016)
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnector(ApplicationStateRunning.java:1961)
         at com.evermind.server.ApplicationStateRunning.initConnector(ApplicationStateRunning.java:1220)
         at com.evermind.server.ApplicationStateRunning.initConnectors(ApplicationStateRunning.java:356)
         at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:208)
         at com.evermind.server.Application.setConfig(Application.java:391)
         at com.evermind.server.Application.setConfig(Application.java:309)
         at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771)
         at com.evermind.server.ApplicationServer.initializeDeployedApplications(ApplicationServer.java:1532)
         at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:939)
         at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:113)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.resource.ResourceException: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:106)
         at oracle.oc4j.sql.DataSourceUtils.getDataSourceConnectionPool(DataSourceUtils.java:322)
         at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:1997)
         ... 11 more
    Caused by: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
         at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:247)
         at oracle.oc4j.sql.DataSourceConnectionPoolImpl.<init>(DataSourceConnectionPoolImpl.java:107)
         at oracle.oc4j.sql.spi.ResourceAdapterImpl.createDataSourceConnectionPool(ResourceAdapterImpl.java:99)
         ... 13 more
    Caused by: oracle.classloader.util.AnnotatedClassNotFoundException:
         Missing class: com.mysql.jdbc.Driver
         Dependent class: oracle.oc4j.sql.config.DataSourceConfigUtils
         Loader: oc4j:10.1.3
         Code-Source: /C:/JDeveloper10g/j2ee/home/lib/oc4j-internal.jar
         Configuration: <code-source> in META-INF/boot.xml in C:\JDeveloper10g\j2ee\home\oc4j.jar
    This load was initiated at current-workspace-app.root:0.0.0 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
         at oracle.classloader.PolicyClassLoader.handleClassNotFound(PolicyClassLoader.java:2061)
         at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1665)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1621)
         at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1606)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:242)
         at oracle.oc4j.sql.config.DataSourceConfigUtils.createConnectionFactory(DataSourceConfigUtils.java:244)
         ... 15 more
    06/01/31 21:41:08 WARNING: Application.setConfig Application: current-workspace-app is in failed state as initialization failedjava.lang.InstantiationException: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    Jan 31, 2006 9:41:08 PM com.evermind.server.Application setConfig
    WARNING: Application: current-workspace-app is in failed state as initialization failedjava.lang.InstantiationException: Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    2006-01-31 21:41:08.531 WARNING J2EE 0JR0013 Exception initializing deployed application: current-workspace-app. Error occurred initializing connectors. Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.mysql.jdbc.Driver
    Ready message received from Oc4jNotifier.
    Embedded OC4J startup time: 29125 ms.

    I did what Manu suggested with no success. Alternatively, I registered the driver jar with embedded OC4J preferences > global > libraries. Still does not work. Please, note, that when I run JUnit tests against my BC4J application modules with JDBC URL as connection type, everything works just fine. The problem comes while running the JSF application when the application module is using JDBC DataSource as connection type.

  • Connecting to MYSQL from RMI Server results SQL Communication fail

    Hi ,
    I have an RMI Server which exports a remote method, which in-turn needs to access content
    from the MYSQL Database.
    PROBLEM: The code snip for RMI Server is given below. In this getChief() is the remote method called
    by the RMI Client running on my same Windows XP machine (ie., localhost).
    I get a slew of exceptions when the DriverManager.getConnection() API call occurs in getChief()
    via the remote method call from the RMI Client. Two exceptions are the SQL Communications failure and Access Denied Socket Exceptions.
    I checked my policy file is OK and MySQL Server is running and my username/password is right in code?
    Can you please let me know what am I missing in the RMI Server code?
    I also found my code works if the Database Connection API is used within main() rather than inside a Remote
    Method...
    The Source and Binary are available in my local Windows XP Machine
    RMI Server: c:/workspace/DirectoryJava/src/server for and c:/workspace/DirectoryJava/bin/server
    RMI Client: c:/workspace/DirectoryJava/src/client for and c:/workspace/DirectoryJava/bin/client
    My security policy file is:
    grant codeBase "file:/workspace/DirectoryJava/bin" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/bin/client" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/bin/server" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/bin/directory" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/src/client" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/src/server" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    grant codeBase "file:/workspace/DirectoryJava/src/directory" {
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
    permission java.net.SocketPermission "*","listen,connect,accept,resolve";
    };I checked that mysqld.exe is running at port 3306 and am able to connect to and use it via
    MySQL Command Client successfully.
    Thanks in advance.
    The Exception list is pasted below.
    c:\workspace\DirectoryJava\bin>java -cp "c:/workspace/Directory
    Java/bin/Directory.jar;c:/workspace/DirectoryJava/bin/server;c:/workspac
    e/DirectoryJava/bin;C:/Program Files/MySQL/mysql-connector-java-5.1.6/my
    sql-connector-java-5.1.6-bin.jar" -Djava.rmi.server.codebase=file:/c:/workspace/
    DirectoryJava/bin/Directory.jar -Djava.security.policy=wideopen.policy
    server.DirectoryEngine
    DirectoryEngine bound
    getChief() Called
    SQLException: Communications link failure
    Last packet sent to the server was 0 ms ago.
    SQLState: 08S01
    VendorError: 0
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai
    lure
    Last packet sent to the server was 0 ms ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1
    074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :282)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at server.DirectoryEngine.getChief(DirectoryEngine.java:91)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou
    rce)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
    ce)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.SocketException: java.security.AccessControlException: acces
    s denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
    at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndT
    hrowIt(StandardSocketFactory.java:404)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:265)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
    ... 26 moreCODE SNIP:
    =========
    public class DirectoryEngine implements Directory {
    public DirectoryEngine() {
    super();
    public Employee getChief() throws RemoteException {
    Statement stmt = null;
    ResultSet rs = null;
    Employee emp = null;
    // TODO Auto-generated method stub
    try {
    System.out.println("getChief() Called");
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306",
    "<username>","<password>");
    // Username and Password were replaced with root username and password in my original code
    System.out.println("getConnection() Called");
    stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    System.out.println("createStatement() Called");
    rs = stmt.executeQuery("use mysql");
    } catch (SQLException ex) {
    // handle any errors
    System.out.println("SQLException: " + ex.getMessage());
    System.out.println("SQLState: " + ex.getSQLState());
    System.out.println("VendorError: " + ex.getErrorCode());
    ex.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    // it is a good idea to release
    // resources in a finally{} block
    // in reverse-order of their creation
    // if they are no-longer needed
    if (rs != null) {
    try {
    rs.close();
    } catch (SQLException sqlEx){
    // ignore
    rs = null;
    if (stmt != null) {
    try {
    stmt.close();
    } catch (SQLException sqlEx) {
    // ignore
    stmt = null;
    return emp;
    } /* getChief() ends */
    public static void main(String[] args) {
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new SecurityManager());
    try {
    String name = "Directory";
    Directory engine = new DirectoryEngine();
    Directory stub =
    (Directory) UnicastRemoteObject.exportObject(engine, 0);
    Registry registry = LocateRegistry.getRegistry();
    registry.rebind(name, stub);
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    System.out.println("DirectoryEngine bound");
    } catch (Exception e) {
    System.err.println("DirectoryEngine exception:");
    e.printStackTrace();
    } /* end DirectoryEngine class */

    It looks there is some permission issue.
    Can you please try once with below policy and let me know the result.
    grant {
      permission java.security.AllPermission;
    };

  • MYSQL JDBC NoClassDefFoundError: org/aspectj/lang/Signature

    i am trying to connect to a database via java using JDBC i have installed:
    jdk1.5.0_01
    mysql-connector-java-3.1.8-bin-g.jar
    MySQL Server 4.1
    Java works fine, MYSQL works fine from the command prompt but when it comes to testing using this simple java program
    public class JdbcExample1 {
    public static void main(String args[]) {
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("localhost", "username", "password");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    this compiles fine but when run i get the following error message
    Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at JdbcExample1.main(JdbcExample1.java:10)
    class path is set as .;C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext\mysql-connector-java-3.1.8-bin.java
    any help or input on this error would be appreciated
    thanks in advanced Neil

    Hi, All:
    I just read this thread of discussion and got valueable info to solve my problem in a similar fashion. I'd suggest the last poster, Anil, to re-read the whole thread to correct the possible problems stated.
    I would just like to add my problem/solution scenario to this thread to share my experience. I assume that readers already went through the previous notes in this thread.
    #1. Space in Path:
    I installed
    MySQL DB server in: "C:\Program Files\MySQL\MySQL Server 4.1"
    MySQL JDBC Driver: D:\mysql\mysql-connector-java-3.1.8
    It seems to me that the DB server installed directory is not affected by whether there is a space in path name. The JDBC Driver path, on the other hand, does have the side effect of the space in path name when accessing by the Java client.
    #2. -g in JDBC Driver:
    I have been using the driver mysql-connector-java-3.1.8-bin.jar. However, right before I needed to create my ant build.xml configuration file (more details later), I thought the instruction asked me to use the mysql-connector-java-3.1.8-bin-g.jar (the debug version as kpreiser indicated), and therefore I got the now-well-known "org/aspectj/lang/Signature" error. After I removed that "-g" from the JDBC driver extression in my build.xml file, it then works well. (Great tip, kpreiser.)
    #3. Middlegen with Hibernate:
    My situation is a bit more complicated, but the issue of "org/aspectj/lang/Signature" error was the same (finally resolved in #2). I was trying to use Middlegen to re-generate my Hibernate map files from the data schema. (Hibernate is an open source tool that lets you create JavaBean source file from a Hibernate map file to map to a database table (see http://www.hibernate.org/ for more details.) Since I re-factored my data schema in the database, I needed to re-generate the Hibernate map files (from data schema) so that I can in turn use the map files to re-generate the JavaBean code. I wanted to use the Middlegen tool (see http://www.hibernate.org/98.html for more details) to re-generate the map files from database schema. However, in order to use Middlegen properly, you need to create the ant build.xml file to do that job. So I had to resort to MiddlegenIDE (see http://ultimania.org/middlegenide/ for more details) to help generate that build.xml file. (This is where I had the -g specified for the JDBC driver in the build.xml file that caused the problem.) Once that build.xml file is generated, the use of ant (a Java make tool) with the build.xml file can generate the hibernate map files. From these map files, JavaBean source files can be generated using Hibernate CodeGenerator.hbm2java tool. (There are several other useful tools in Hibernate too to convert the database ddl schema and the JavaBean source file.)
    Obviously, there are other approaches and tools that you can use (XDoclet for instance) for different situations, but I am only providing a high level overview on what you can do to be more productive if you are involved in a large and complicated project with Java/JDBC and ORM (Object/Relational Mapping).
    Item #3 may sound complicated at first, but it's worth the time to learn the tools and concept. Once you are familiar with these tools (Eclipse, Hibernate, Middlegen, Ant, etc.), you will become more productive in responding to the dynamic nature of the high-tech world where changing requirements are the only constant. I hope that these separate tools will become more integrated and easier to use in the future, but for now they do the job well.
    Thanks for the great tips and hope that this helps too.
    - Shuh

  • Connection mysql jdbc error ?

    I have program java likes this :
    import java.sql.*;
    public class LoadDriver {
        // Define the JDBC Driver and the database connection URL
        public static final String DRIVER = "com.mysql.jdbc.Driver";
        public static final String URL = "jdbc:mysql://localhost/java?user=test&password=test";
        public static void main(String args[]) {
            Connection conn = null;
    Statement select = null;
    ResultSet result = null;
            try {
                // load the driver dynamically
                Class.forName(DRIVER);
                // connect to the database
                conn = DriverManager.getConnection(URL);
                // perform a query. first create a Statement object from the connection
                select = conn.createStatement();
    // next execute a query (SQL string) and return the results in a ResultSet object
                result = select.executeQuery("select fname, lname from names order by lname, fname");
                // print out the results
                while(result.next()) {
                    String fname = result.getString("fname"); // note these match the columns in the
                    String lname = result.getString("lname"); // SELECT statement (fname, lname)
                    System.out.println(fname+" "+lname);
    // check if there was a problem executing the SQL statement
            catch (SQLException e) {
                System.err.println("SQL Exception: "+e.getMessage());
                System.exit(1);
    // if the JDBC driver is not in the CLASSPATH
            catch (ClassNotFoundException e) {
                System.err.println("Class not found:  "+e.getMessage());
                System.exit(1);
    // catch any other exceptions
            catch (Exception e) {
                System.err.println("Other Exception: ");
                System.err.println(e.getMessage());
                System.exit(1);
    // You want to close the connections no matter what happens!
    finally {
    try {
    // close the result, query, and database connection
    if (result != null) result.close();
                 if (select != null) select.close();
                if (conn != null) conn.close();
    catch (SQLException e) {
    // one of the new cases where it's OK to just eat exceptions or at the most log them
    System.err.println("Error closing connection: "+e.getMessage());
      but i get errror likes this :
    D:\Program Files\Java\jdk1.5.0_03\bin>javac LoadDriver.java
    D:\Program Files\Java\jdk1.5.0_03\bin>java LoadDriver
    Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Sign
    ature
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at LoadDriver.main(LoadDriver.java:20)
    D:\Program Files\Java\jdk1.5.0_03\bin>
    I place mysql.jar in
    - D:\Program Files\Java\jdk1.5.0_03\jre\lib\ext
    - D:\Program Files\Java\jdk1.5.0_03\lib
    - D:\Program Files\Java\jdk1.5.0_03\jre\lib
    and i make classpath to D:\Program Files\Java\jdk1.5.0_03\bin;D:\Program Files\Java\jdk1.5.0_03\jre\lib\ext\
    but it still doesn't work
    What must I do ?
    Thx 4 your reply

    Hello!
    I'm getting this same error message and i followed the code example as close as i could:
    Thanks for any help on this!
    bk
    set oldpath=%PATH%
    set JAVA_HOME=C:\jdk1.5.0_02
    set ANT_HOME=C:\ANT\apache-ant-1.6.5
    set PATH=C:\jdk1.5.0_02\bin;%ANT_HOME%\bin
    set CLASSPATH=.;C:\jdk1.5.0_02\lib;C:\MYSQL\mysql-connector-java-3.1.10\src\com\;C:\MYSQL\mysql-connector-java-3.1.10\src\org\;C:\MYSQL\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin-g.jar;
    http://www.developer.com/java/data/article.php/3417381#Critical_steps_in_using_JDBC
    import java.sql.*;
    public class Jdbc11 {
      public static void main(String args[]){
        System.out.println(
                      "Copyright 2004, R.G.Baldwin");
        try {
          Statement stmt;
          //Register the JDBC driver for MySQL.
          Class.forName("com.mysql.jdbc.Driver");
          //Define URL of database server for
          // database named mysql on the localhost
          // with the default port number 3306.
          String url =
                "jdbc:mysql://localhost:3306/mysql";
          //Get a connection to the database for a
          // user named root with a blank password.
          // This user is the default administrator
          // having full privileges to do anything.
          Connection con =
                         DriverManager.getConnection(
                                     url,"root", "");
          //Display URL and connection information
          System.out.println("URL: " + url);
          System.out.println("Connection: " + con);
          //Get a Statement object
          stmt = con.createStatement();
          //Create the new database
          stmt.executeUpdate(
                           "CREATE DATABASE JunkDB");
          //Register a new user named auser on the
          // database named JunkDB with a password
          // drowssap enabling several different
          // privileges.
          stmt.executeUpdate(
              "GRANT SELECT,INSERT,UPDATE,DELETE," +
              "CREATE,DROP " +
              "ON JunkDB.* TO 'auser'@'localhost' " +
              "IDENTIFIED BY 'drowssap';");
          con.close();
        }catch( Exception e ) {
          e.printStackTrace();
        }//end catch
      }//end main
    }//end class Jdbc11
    Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature

  • Error : class not found exception : com.mysql.jdbc.driver in Eclipse Tool

    Hi
    I have impoted project file in eclipse in new machine using option import from existing workbence . When i stat to debug this project ,
    i am getting error as class not found exception : com.mysql.jdbc.driver . my project folder already consist of mysql .jar file in /web appls/web-inf folder.
    Application is running successfully in other machine from where i took the application file. As this error appeared I also added jar file into project path as Project ---->properties-- build java path---libraries----add external jar file.
    kindly hep me.

    Sounds like an eclipse question - not a JDBC one.
    But since eclipse is telling you it can't find it then it means it is not in the eclipse path. So you must add it. (The fact that it is somewhere is irrelevant - all that matters is it is not in the class path.)

  • Error in Class.forName("com.mysql.jdbc.driver")

    Hi forum,
    Please help me to solve the issue.
    im using the following jsp code for genrating the reports using JASPER REPORTS
    the JSP FILE
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="javax.sql.DataSource"%>
    <%@ page import="javax.naming.InitialContext"%>
    <%@ page import="net.sf.jasperreports.engine.*"%>
    <%@ page import="net.sf.jasperreports.engine.design.JasperDesign"%>
    <%@ page import="net.sf.jasperreports.engine.xml.JRXmlLoader"%>
    <%@ page import="net.sf.jasperreports.engine.export.*" %>
    <%@ page import ="net.sf.jasperreports.engine.*"%>
    <%@ page import ="net.sf.jasperreports.engine.JasperFillManager"%>
    <%@ page import ="net.sf.jasperreports.engine.JRException"%>
    <%@ page import="net.sf.jasperreports.engine.JasperReport"%>
    <%@ page import="net.sf.jasperreports.engine.JasperPrint"%>
    <html>
    <body bgcolor="00ffcc">
    <%
    try{
    Connection con = null;
    String url="jdbc:mysql://localhost/customer";
    String username = "root";
    String password = "cmsadmin";
    InputStream input=new FileInputStream(new File("C:/Documents and Settings/user/My Documents/NetBeansProjects/jasperreports/web/helloworld.xml"));
    JasperDesign design = JRXmlLoader.load(input);
    JasperReport report = JasperCompileManager.compileReport(design);
    Map params = new HashMap();
    params.put("reportTitle", "helloworld");
    params.put("author", "Muthu Kumar");
    params.put("startDate", (new java.util.Date()).toString());
    params.put("ReportTitle", "PDF JasperReport");
    <img class="emoticon" src="images/emoticons/confused.gif" border="0" alt="" />Class.forName("com.mysql.jdbc.Driver");<img class="emoticon" src="images/emoticons/confused.gif" border="0" alt="" /><img src="images/emoticons/confused.gif" border="0" alt="" />
    con = DriverManager.getConnection(url,username,password);
    JasperPrint print = JasperFillManager.fillReport(report, params, con);
    OutputStream output=new FileOutputStream(new File("C:/Documents and Settings/user/My Documents/NetBeansProjects/jasperreports/helloreportworld.pdf"));
    JasperExportManager.exportReportToPdfStream(print, output);
    // JasperViewer.viewReport(print);
    catch(SQLException es) {
    out.println(es);
    catch(JRException ex){
    //ex.printStackTrace();
    out.println(ex);
    %>
    </body>
    </html>The error it is saying is in the line Class.forName(....) ;
    Please look for the emoctions with question mark
    i DOn know what to do.
    Please help
    Im comparin the below JRXML file as with the above code
    <?xml version="1.0"?>
    <!DOCTYPE jasperReport
    PUBLIC "-//JasperReports//DTD Report Design//EN"
    "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
    <jasperReport name="helloworld">
    <parameter name="reportTitle" class="java.lang.String"/>
    <parameter name="author" class="java.lang.String"/>
    <parameter name="startDate" class="java.lang.String"/>
    <queryString>
    <![CDATA[SELECT * FROM customer order by UserID ]]>
    </queryString>
    <field name="UserID" class="java.lang.String"/>
    <field name="UserName" class="java.lang.String"/>
    <field name="City" class="java.lang.String"/>
    <field name="State" class="java.lang.String"/>
    <title>
    <band height="60">
    <textField>
    <reportElement x="0" y="10" width="500" height="40"/>
    <textElement textAlignment="Center">
    <font size="24"/>
    </textElement>
    <textFieldExpression class="java.lang.String">
    <![CDATA[$P{reportTitle}]]>
    </textFieldExpression>
    </textField>
    <textField>
    <reportElement x="0" y="40" width="500" height="20"/>
    <textElement textAlignment="Center"/>
    <textFieldExpression class="java.lang.String">
    <![CDATA["Run by: " + $P{author}
    + " on " + $P{startDate}]]>
    </textFieldExpression>
    </textField>
    </band>
    </title>
    <columnHeader>
    <band height="30">
    <rectangle>
    <reportElement x="0" y="0" width="500" height="25"/>
    <graphicElement/>
    </rectangle>
    <staticText>
    <reportElement x="5" y="5" width="50" height="15"/>
    <textElement/>
    <text><![CDATA[UserID]]></text>
    </staticText>
    <staticText>
    <reportElement x="55" y="5" width="150" height="15"/>
    <text><![CDATA[UserName]]></text>
    </staticText>
    <staticText>
    <reportElement x="205" y="5" width="255" height="15"/>
    <text><![CDATA[City, State]]></text>
    </staticText>
    </band>
    </columnHeader>
    <detail>
    <band height="20">
    <textField>
    <reportElement x="5" y="0" width="50" height="15"/>
    <textElement/>
    <textFieldExpression class="java.lang.String">
    <![CDATA[$F{UserID}]]>
    </textFieldExpression>
    </textField>
    <textField>
    <reportElement x="55" y="0" width="150" height="15"/>
    <textElement/>
    <textFieldExpression class="java.lang.String">
    <![CDATA[$F{UserName}]]>
    </textFieldExpression>
    </textField>
    <textField>
    <reportElement x="205" y="0" width="255" height="15"/>
    <textElement/>
    <textFieldExpression class="java.lang.String">
    <![CDATA[$F{City} + ", " + $F{State}]]>
    </textFieldExpression>
    </textField>
    </band>
    </detail>
    </jasperReport>

    Glass_Fish wrote:
    I have set the classpath in the environment variables in the my computer properties.The web container has it's own properties. The "system" classpath means absolutely nothing to it. Read your server's documentation.

  • MySQL /JDBC Question

    I began playing with JDBC a few days ago. I set up a database using mySQL and wrote a simple java program that will connect to it. Works good from the computer that holds the database.
    I try and run the same program from my secondary computer which does not have mySQL or ODBC mySQL drivers, I get com.mysql.jdbc.Driver for an error message. (Trying to access the database on my main computer via ip/databasename)
    My Question is, do you HAVE to have mySQL or Connector/ODBC installed on a computer if you wish to connect to a database on other computer??
    Here's where it prints the error message...
    try
    Class.forName("com.mysql.jdbc.Driver");
    catch (Exception e)
    JOptionPane.showMessageDialog(null, "ERROR = " + e.getMessage());
    I use this as my url..
    private final String url = "jdbc:mysql://122.122.122.122:3306/test123";
         

    Say I want to make a simple web applet that will
    access a database on my computer. The only way my
    vistors to my website will be able to access the
    database via the web applet is by having mySQL JDBC
    driver installed on their computers?yes.
    however.
    you can package up the JDBC driver as part of your jar with your applet so it doesn't require the user to "install" anything. it's just part of your applet.

  • NullPointerException in weblogic.jdbc.rmi.SerialConnection.createStatement()

    Hello,
    we are running WLS 6.1 SP2. The following code sometimes (rather rarely) throws
    a NullPointerException:
    Connection dbConnection = DBUtil.getDBConnection();//here we get the Connection
    stmt = dbConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);//it's
    where NPE happens
    The error report says:
    java.sql.SQLException:
    java.lang.NullPointerException at
    weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:396)
    So, I think, this is something in WebLogic's code... Is this a known issue (I
    couldn't find a similar report in the newsgroup)? Is there a workaround?
    regards,
    Vitaly

    Vitaly Sourikov wrote:
    "Vitaly Sourikov" <[email protected]> wrote:
    The patches that we use with SP2 are
    CR061106_61sp2.jar
    CR072612_61sp2.jar
    CR077919_61sp2.jar
    As far as we know, those fixes (or some of them) were not introduced in SP4. Are
    there new versions of the patches for SP4?I have found that all these bugs are fixed in sp4, so no patches are needed if you
    upgrade to 6.1sp4.
    Joe
    >
    >
    regards,
    Vitaly
    Hi Joseph,
    Thank you for the reply. Unfortunately, we cannot move to SP3 or SP4
    - they have
    conflicts with other patches from WebLogic we use. This error happens
    rather rarely.
    In most of cases this very stuff works. But it would be intresing to
    have this
    patch for diagnostics, in case of future failures. Would you send it
    to me, please?
    Thank you in advance,
    Vitaly
    Joseph Weinstein <[email protected]> wrote:
    Vitaly Sourikov wrote:
    Hello,
    we are running WLS 6.1 SP2. The following code sometimes (rather rarely)throws
    a NullPointerException:
    Connection dbConnection = DBUtil.getDBConnection();//here we get theConnection
    stmt = dbConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);//it's
    where NPE happens
    The error report says:
    java.sql.SQLException:
    java.lang.NullPointerException at
    weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:396)
    So, I think, this is something in WebLogic's code... Is this a knownissue (I
    couldn't find a similar report in the newsgroup)? Is there a workaround?Hi. The NPE is probably happening in the actual DBMS driver. What is
    happening
    is that the rmi driver is having to catch any non-SQLException, andthrow
    a SQLException
    with the message of the original exception. Unfortunately, the fullstacktrace
    of the
    original NPE is lost. If you want, I can send you a small diagnostic
    patch, which will
    just make the rmi object retain the whole original stacktrace in the
    exception it throws,
    and that will help lead to the real problem.
    This may well be a bug that was fixed in sp3 or 4. Is it possible
    for you to upgrade to
    the latest stuff?
    Joe
    regards,
    Vitaly

  • ClassCastException: weblogic.jdbc.rmi.SerialResultSet

    HI,
    I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from Oracle database.
    It is working fine to get the connection and get non-CLOB data like string, but
    when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
    rs).getCLOB(1),
    Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet, does anybody
    experience the same problem ? How can I get around this problem ?
    Thanks
    John

    Hi,
    I've got the same error. The only diference is that I read BLOBs out of the table
    ((oracle.jdbc.OracleResultSet)rset).getBLOB(1) from oracle.jdbc.OracleResultSet).
    Best regards,
    Kai
    "John Chen" <[email protected]> wrote:
    >
    HI,
    I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from
    Oracle database.
    It is working fine to get the connection and get non-CLOB data like string,
    but
    when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
    rs).getCLOB(1),
    Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet,
    does anybody
    experience the same problem ? How can I get around this problem ?
    Thanks
    John

  • Loadjava mysql jdbc - error

    Hi!
    I´m Trying to load the mysql connector into oracle database.
    I create a package to connect to mysql and all that is missing is the jdbc driver.
    So i executed loadjava, but i´m getting the error bellow. Can anyone help me?
    Oracle database 10g
    arguments: '-u' 'vendas/***@idev10g' '-v' '-resolve' '/ora10g/app/oracle/product/10.2.0/db_1/jlib/mysql-connector-java-5.1.12.jar'
    dropped  : JAVA$CLASS$MD5$TABLE
    Exception in thread "main" java.lang.UnsatisfiedLinkError: getClassContext
            at com.ibm.jvm.classloader.ClassLoaderUtils.getLastClassLoader(ClassLoaderUtils.java:38)
            at java.security.Provider.loadProvider(Provider.java:209)
            at java.security.Security$2.run(Security.java:434)
            at java.security.AccessController.doPrivileged1(Native Method)
            at java.security.AccessController.doPrivileged(AccessController.java:351)
            at java.security.Security.getProviderAt(Security.java:431)
            at java.security.Security.getAlgClassName(Security.java:583)
            at java.security.Security.getAlgClassName(Security.java:637)
            at java.security.Security.getImpl(Security.java:1118)
            at java.security.MessageDigest.getInstance(MessageDigest.java:135)
            at oracle.aurora.server.tools.loadjava.SchemaObject.MD5OfStream(SchemaObject.java:730)
            at oracle.aurora.server.tools.loadjava.SchemaObject.getNewMD5(SchemaObject.java:418)
            at oracle.aurora.server.tools.loadjava.SchemaObject.doCreate(SchemaObject.java:174)
            at oracle.aurora.server.tools.loadjava.SchemaObject.process1(SchemaObject.java:215)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:548)
            at oracle.aurora.server.tools.loadjava.LoadJava.addObject(LoadJava.java:529)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:467)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:396)
            at oracle.aurora.server.tools.loadjava.LoadJava.addJar(LoadJava.java:743)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:448)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:396)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:365)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:668)
            at oracle.aurora.server.tools.loadjava.LoadJava.processDeferredFiles(LoadJava.java:633)
            at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:834)
            at oracle.aurora.server.tools.loadjava.LoadJava.command(LoadJava.java:267)
            at oracle.aurora.server.tools.loadjava.LoadJavaMain.run(LoadJavaMain.java:164)
            at oracle.aurora.server.tools.loadjava.LoadJavaMain.main(LoadJavaMain.java:89)

    I solved it.
    I had to increase the java pool memory (first time i run the server complained about it) and then load the mysql jdbc driver executing in sqlplus:
    dbms_java.loadjava('path to jdbc driver file');
    When executing from console, the loadjava command require extra information (LD_LIBRARY_PATH etc) giving the error i mention above.
    Executing from sqlplus it is all set.

  • MySQL JDBC Performance Issues

    Hi, First off, let me admit, im a java newbie. I've been using java for about 6 months now, although im a fast learner, some things still elude me.
    I've searched these forums and google high and low for an answer to my question before signing up and posting here, so i'm kind of at my wits end.
    Let me explain my specs so noone blames lack of power for this issue.
    System specs:
    Linux Cent OS 4 2.6.19 SMP
    JRE 1.6
    MySQL 4.2.2 ICC Compiled Enterprise Edition
    4x HyperThreaded Xeon 1.9Ghz cpus (Displays as 8)
    16GB ECC Double-Parity Double-Buffered Memory. (Rediculous IBM proprietary memory)
    Problem:
    I first wrote this application in PHP as it my stong suit (that should tell you plenty). But the PHP CLI was eating up way to much CPU power/MySQL bandwith to execute this script, and taking way to long, so i started re-writing it in C++, well when my feeble C++ powers failed me, i went to Java. I know more Java then C++ but i picked C first because i thought it would be the fastest. Java, however, is slower then PHP when i write the identical logic, i dont know if i should blame Java or my assumption that i can copy logic from one language to another.
    Here is the details:
    I have 1 MySQL database and 2 Tables im pulling from, This mysql database is optimized by the people from MySQL, so i know its not the DB, Server, or Tables. 1 table (bfpax) has around 45k rows (45000), the second table (bfbdet) has around 100k rows (100000). What this program has to do, its objective, is:
    1. Pull the indexed ID from table 1;
    2. With that ID, pull other data from table 2 and table 1 for each ID;
    3. Compile that data together for each ID
    4. Insert compiled data into a HEAP table for fast access for each ID.
    In PHP (pseudocode):
    SELECT ID FROM bfpax;
    Loop:
    Foreach id pull various data pieces i.e. name, client code, address, zip, etc.
    String format name: "A-GARY/COLE" becomes "Gary/Cole"
    String format hotel: "ACUNMIP" becomes CUNMIP
    Insert all formatted/fixed data into heap table
    End loop.
    In Java (pseudocode):
    SELECT ID FROM cpax;
    Loop:
    Create object with ID as constructor variable (see below for object declaration) and add to an arrayList;
    End Loop;
    Create 6 threads to execute each of the objects methods for data collection/formatting
    Start each thread using inner classes to loop through the object arraylist and execute dedicated methods per thread.
    Thread 1: Pull air data
    Thread 2: Pull destination
    Thread 3: Pull hotel
    Thread 4: Pull gateway
    Thread 5: Pull the rest (price, dates, etc)
    Thread 6: Start executing the update method
    The above kind of failed, so i reduced the complexity by nuking the whole thread idea and now i just have a simple function that loops through the arraylist of objects and executes each method in order.
    Booking Object:
    public class Booking extends ReportingConstants{
        private ArrayList<String> myData = new ArrayList<String>();
        private int myBookNum;
        private static Connection myCon;
        public static int numBookings;
        public int updateCount = 0;
        public boolean isFinished = false;
        public Booking(int booking_number, Connection conn) {
            if (booking_number > 9999) {
                myBookNum = booking_number;
            numBookings++;
            myCon = conn;
            //Run loop to make sure myData has the proper spaces for insert, ensureCapacity didnt work.
            for (int i = 0; i < 15; i++) {
                myData.add("");
            myData.set(_BOOKNUM,String.valueOf(myBookNum));
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 0) {
                System.out.println("Initialized booking number "+myBookNum+" count "+numBookings);
        public void getAir() {
            ResultSet res;
            ArrayList<String> total_air = new ArrayList<String>();
            String airlines = "";
            String query = "SELECT operator_id FROM EDITED.bfbdet WHERE record_type = 'A' AND item_desc LIKE '-%' AND booking_number = "+myBookNum+" AND operator_id IS NOT NULL";
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                System.out.println("Starting Air: "+query);
            res = MySQL.sqlQuery(query,myCon,5);
            try {
                while(res.next()) {
                    if (res.getString(1).length() > 1) {
                        String id = res.getString(1).substring(0,2);
                        if (!total_air.contains(id)) {
                            airlines += id+",";
                        total_air.add(id);
                res.close();
                MySQL.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            myData.set(_AIR,airlines);
            updateCount++;
        public void getDest() {
            String query = "SELECT booking_code FROM EDITED.bfpax WHERE booking_number = "+myBookNum+" LIMIT 1";
            ResultSet res;
            String isSv ="Y";
            String dest;
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                System.out.println("Starting Dest: "+query);
            res = MySQL.sqlQuery(query,myCon,1);
            try {
                while (res.next()) {
                    dest = res.getString(1).substring(1,4);
                    if (dest != "FRE") {
                        if (dest == "GYY") {
                            String realDest = res.getString(1).substring(4,2);
                            if (realDest == "GY") {
                                dest = "GYY";
                            } else if (realDest == "MC") {
                                dest = "MCO";
                            } else if (realDest == "FL") {
                                dest = "FLL";
                            } else if (realDest == "IW") {
                                dest = "IWA";
                            } else if (realDest == "PI") {
                                dest = "PIE";
                            } else if (realDest == "LA") {
                                dest = "LAS";
                            } else {
                                dest = "GYY";
                        } else {
                            isSv = "N";
                        myData.set(_DEST,dest);
                        myData.set(_SV,isSv);
                        updateCount++;
                res.close();
                MySQL.close();
            } catch (Exception ex) {
                ex.printStackTrace();
        public void getGateway() {
            String query = "SELECT item_desc FROM EDITED.bfbdet WHERE (booking_number = '"+myBookNum+"' OR booking_number = ' "+myBookNum+"') AND item_desc LIKE '-%' ORDER BY booking_suffix ASC LIMIT 1";
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                System.out.println("Starting GW: "+query);
            ResultSet res = MySQL.sqlQuery(query,myCon,1);
            String gw;
            try {
                while (res.next()) {
                    gw = res.getString(1).substring(1,3);
                    myData.set(_GW,gw);
                updateCount++;
                res.close();
                MySQL.close();
            } catch (Exception ex) {
                ex.printStackTrace();
        public void getHotel() {
            String query = "SELECT operator_id FROM EDITED.bfbdet WHERE record_type = 'H' AND (booking_number = '"+myBookNum+"' OR booking_number = ' "+myBookNum+"') LIMIT 1";
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                System.out.println("Starting Hotel: "+query);
            ResultSet res = MySQL.sqlQuery(query,myCon,1);
            String hotel = "";
            try {
                while (res.next()) {
                    hotel = res.getString(1).substring(0,6);
                    if (myData.get(_DEST) == "") {
                        myData.set(_DEST,res.getString(1).substring(0,3));
                        updateCount++;
                myData.set(_HOTEL,hotel);
                updateCount++;
                res.close();
                MySQL.close();
            } catch (Exception ex) {
                ex.printStackTrace();
        public void getRest() {
            String query = "SELECT client_code, passenger1_name, agentid, booked_date, dep_date, total_price, total_received, total_commission, number_pax FROM EDITED.bfpax WHERE booking_number = "+myBookNum+" LIMIT 1";
            if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                System.out.println("Starting Rest: "+query);
            ResultSet res = MySQL.sqlQuery(query,myCon,1);
            try {
                while (res.next()) {
                    myData.set(_AGENCY,res.getString(1));
                    if (res.getString(3) != "null") {
                        myData.set(_AGENT,res.getString(3));
                    } else {
                        myData.set(_AGENT,"");
                    myData.set(_PAXNAME,res.getString(2).replace("'",""));
                    myData.set(_BKDATE,String.valueOf(res.getDate(4)));
                    myData.set(_DEPDATE,String.valueOf(res.getDate(5)));
                    myData.set(_TPRICE,String.valueOf(res.getDouble(6)));
                    myData.set(_TRECV,String.valueOf(res.getDouble(7)));
                    myData.set(_TCOM,String.valueOf(res.getDouble(8)));
                    myData.set(_NUMPAX,String.valueOf(res.getInt(9)).trim());
                    //System.out.println("NUMPAX: |"+myData.get(_NUMPAX)+"|");
                updateCount++;
                res.close();
                MySQL.close();
            } catch(Exception ex) {
                ex.printStackTrace();
        public void storeData() {
            if (!isFinished) {
                String query = "INSERT INTO "+tmpTable+" (`booking_number`, `destination`, `gateway`, `airline`, `hotel`, `agency`, `agent`, `booked_date`, `dep_date`, `total_price`, `total_received`, `total_commission`, `number_pax`, `passenger_name`, `is_skyvalue`) VALUES('"+myData.get(0)+"','"+myData.get(1)+"','"+myData.get(2)+"','"+myData.get(3)+"','"+myData.get(4)+"','"+myData.get(5)+"','"+myData.get(6)+"','"+myData.get(7)+"','"+myData.get(8)+"','"+myData.get(9)+"','"+myData.get(10)+"','"+myData.get(11)+"','"+myData.get(12)+"','"+myData.get(13)+"','"+myData.get(14)+"')";
                if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
                    System.out.println(query);
                MySQL.sqlExec(query,myCon);
                isFinished = true;
                if (Integer.valueOf(_ARGS[_DEBUG][1]) > 0) {
                    System.out.println("Booking number "+myBookNum+" is finished!");
            } else {
                //System.out.println("Not fully populated!");
    }Please dont laugh too hard heh, i know my code is sloppy and probably not optimized at all, i dont pretend to be a hardcore java guy, but i would love to learn. Im also posting below my static MySQL class so you can see what happens when i call sqlQuery();
    public abstract class MySQL {
        private static ResultSet res;
        private static Statement stmt;
        public static ResultSet sqlQuery(String query,Connection con, int limit) {
            try {
                stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                stmt.setFetchSize(limit);
                res = stmt.executeQuery(query);
            } catch(Exception ex) {
                ex.printStackTrace();
                res = null;
                System.out.println("Cant Query!: "+query);
            return res;
        public static void sqlExec(String query,Connection con) {
            Statement stmt;
            try {
                stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                stmt.executeUpdate(query);
                stmt.close();
            } catch(Exception ex) {
                ex.printStackTrace();
                System.out.println("Cant Query!: "+query);
        public static void close() {
            try {
                stmt.close();
                res.close();
            } catch (Exception ex) {
                ex.printStackTrace();
    }If you notice, i require the connection to be passed when executing a query, i do this because even if i made a static connection state in the MySQL class, for some reason, it still gets duplicated every time its called. This way, i create 1 connection with the calling static main class, and pass that same conn back and forth through the whole script. I know in PHP this is the best way to do it, in Java it may require many different connections.
    By the way, this is an update that runs once per hour, it does not have to worry about users or anything like that, it gets executed by cron on the hour.
    PHP does this job of updating about 40000 entries in 9-12 minutes. for an average of 0.0135 seconds per entry, Java rolls around at 0.06 seconds per query, 6x slower, this puts execution time at about 40 minutes, obviously this is an issue if its supposed to run every hour. The java app does not tax the system, on top/htop it does not even make it to the first page so its not resources, ive looked at the verbose gc info, and i didnt see anything to clue me in there either.
    I'm sure this is a simple error and my lack of knowledge with Java is what's holding me back, but if i cant figure this out ill have to go back to struggling with C++.
    Thanks in advance, and im sorry for the horribly long post.
    Thanks,
    Dave

    I didnt want to include this in the original post, so here is where my main is located:
    public class ReportingUpdate extends ReportingConstants {
        private ArrayList bookings;
        private static String[] argList;
        private static ArrayList<String> provArg = new ArrayList<String>();
        public ArrayList notDone = new ArrayList();
        private static Connection conn;
        public int bookingsUpdated;
        public static boolean isUpdating = false;
        private static int _ERRORS = 0;
        public static ArrayList doneBookings = new ArrayList();
        public static void main(String[] args) {
            if (args.length > 0) {
                if (args[0].contains("-help")) {
                    printHelp();
                } else {
                    setupArgs();
                    argList = args;
                    parseArgs();
            if (_ERRORS == 0) {
                new ReportingUpdate().go();
            } else {
                return;
        private static void parseArgs() {
            for (String s : argList) {
                if (s.indexOf("-") != 0) {
                    printHelp();
                    break;
                if (s.length() > 2) {
                    provArg.add(s.substring(1,2));
                } else {
                    printHelp();
                    break;
            for (int i = 0; i < _ARGS.length; i++) {
                if (provArg.contains(_ARGS[0])) {
    int pos = provArg.indexOf(_ARGS[i][0]);
    ReportingConstants._ARGS[i][1] = argList[pos].substring(2);
    //Commented out argument testing loop.
    /*for (String[] s : _ARGS) {
    System.out.println("Arg: "+s[0]+" Value: "+s[1]);
    _ERRORS++;*/
    public static void printHelp() {
    System.out.println("\nReporting Update 1.1 (2007 February 1, compiled Feb 19 2007 11:12:24)");
    System.out.println("");
    System.out.println("Usage: java -jar /path/to/ReportingUpdate.jar [arguments]");
    System.out.println("");
    System.out.println("Arguments:");
    System.out.println(" -d<level>\tDebug Level: 0-No Output(Default), 1-Start and finish output, 2-Functional Output(Lots of output)");
    System.out.println(" -l<limit>\tBooking Limit. How many bookings will be updated, only use this for testing.");
    System.out.println(" -a<0,1> \tBool choice to run the air update function, speed testing option. (0-0ff,1-On)\n \t\tIf this is not set, on is assumed");
    System.out.println(" -e<0,1> \tSame as above, but for destination.");
    System.out.println(" -g<0,1> \tSame as above, but for gateway.");
    System.out.println(" -h<0,1> \tSame as above, but for hotel.");
    System.out.println(" -r<0,1> \tSame as above, but for agency,agent,price & dates.");
    System.out.println(" -u<0,1> \tSame as above, but for each bookings actual insert into the db.");
    System.out.println("");
    System.out.println("Example: java -jar /path/to/ReportingUpdate.jar -d1 -l500 -a0 -d0 -u0");
    System.out.println("Run the reportingupdate with debug level 1, limit 500 bookings and do not run the air, destination or insert functions.\n");
    _ERRORS++;
    public void go() {
    String limitString;
    if (Integer.valueOf(_ARGS[_LIMIT][1]) > 0) {
    limitString = "LIMIT "+_ARGS[_LIMIT][1];
    } else {
    limitString = "";
    bookings = new ArrayList();
    ResultSet res;
    connect();
    res = MySQL.sqlQuery("SELECT booking_number FROM EDITED.bfpax WHERE booking_number IS NOT NULL "+limitString,conn,Integer.valueOf(_ARGS[_LIMIT][1]));
    try {
    int i = 0;
    while (res.next()) {
    String booking = res.getString("booking_number");
    booking = booking.trim();
    if (booking.length() > 1) {
    //System.out.println("Reading booking "+booking);
    bookings.add(new Booking(Integer.valueOf(booking),conn));
    i = 1;
    startTheFire();
    } catch(Exception ex) {
    ex.printStackTrace();
    private void startTheFire() {
    /*Thread a = new Thread(new DoAir());
    Thread b = new Thread(new DoDest());
    Thread c = new Thread(new DoGW());
    Thread d = new Thread(new DoHotel());
    Thread e = new Thread(new DoRest());
    Thread f = new Thread(new DoUpdate());
    a.setName("Air");
    a.start();
    b.setName("Dest");
    b.start();
    c.setName("GW");
    c.start();
    d.setName("Hotel");
    d.start();
    e.setName("Rest");
    e.start();
    f.setName("Update");
    f.start();
    try {
    f.sleep(20000);
    } catch (Exception ex) {
    ex.printStackTrace();
    Iterator it = bookings.iterator();
    while (it.hasNext()) {
    Booking b = (Booking) it.next();
    if (Integer.valueOf(_ARGS[_AIRARG][1]) > 0) {
    b.getAir();
    if (Integer.valueOf(_ARGS[_DESTARG][1]) > 0) {
    b.getDest();
    if (Integer.valueOf(_ARGS[_GWARG][1]) > 0) {
    b.getGateway();
    if (Integer.valueOf(_ARGS[_HOTELARG][1]) > 0) {
    b.getHotel();
    if (Integer.valueOf(_ARGS[_RESTARG][1]) > 0) {
    b.getRest();
    if (Integer.valueOf(_ARGS[_UPDATEARG][1]) > 0) {
    b.storeData();
    class DoAir implements Runnable {
    public void run() {
    Iterator it = bookings.iterator();
    while(it.hasNext()) {
    Booking tempBooking = (Booking) it.next();
    tempBooking.getAir();
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("Air is done!");
    class DoDest implements Runnable {
    public void run() {
    Iterator it = bookings.iterator();
    while(it.hasNext()) {
    Booking tempBooking = (Booking) it.next();
    tempBooking.getDest();
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("Dest is done!");
    class DoGW implements Runnable {
    public void run() {
    Iterator it = bookings.iterator();
    while(it.hasNext()) {
    Booking tempBooking = (Booking) it.next();
    tempBooking.getGateway();
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("Gateway is done!");
    class DoHotel implements Runnable {
    public void run() {
    Iterator it = bookings.iterator();
    while(it.hasNext()) {
    Booking tempBooking = (Booking) it.next();
    tempBooking.getHotel();
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("Hotel is done!");
    class DoRest implements Runnable {
    public void run() {
    Iterator it = bookings.iterator();
    while(it.hasNext()) {
    Booking tempBooking = (Booking) it.next();
    tempBooking.getRest();
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("The Rest is done!");
    class DoUpdate implements Runnable {
    public void run() {
    while (bookingsUpdated <= Booking.numBookings) {
    if (doneBookings.size() > 0) {
    isUpdating = true;
    Iterator it = doneBookings.iterator();
    while (it.hasNext()) {
    Booking b = (Booking) it.next();
    b.storeData();
    bookingsUpdated++;
    it.remove();
    isUpdating = false;
    if (Integer.valueOf(_ARGS[_DEBUG][1]) > 1) {
    System.out.println("Update is done!");
    private void connect() {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection(_URL,_USER,_PASS);
    } catch(Exception ex) {
    System.out.println("Cannot Connect to: "+_URL);
    ex.printStackTrace();
    createTempTable();
    private void createTempTable() {
    String create_query = "CREATE TABLE IF NOT EXISTS `"+tmpTable+"` (`ID` INT( 5 ) NOT NULL AUTO_INCREMENT ,`booking_number` INT( 6 ) NULL ,`destination` CHAR( 3 ) NULL ,`gateway` CHAR( 3 ) NULL ,`airline` VARCHAR( 15 ) NULL ,`hotel` CHAR( 6 ) NULL ,`agency` VARCHAR( 15 ) NULL ,`agent` VARCHAR( 20 ) NULL ,`booked_date` VARCHAR( 10 ) NULL ,`dep_date` VARCHAR( 10 ) NULL ,`total_price` VARCHAR( 10 ) NULL ,`total_received` VARCHAR( 10 ) NULL ,`total_commission` VARCHAR( 10 ) NULL ,`number_pax` INT( 5 ) NULL ,`passenger_name` VARCHAR( 50 ) NULL,`is_skyvalue` CHAR( 1 ) NULL,PRIMARY KEY ( `ID` ),INDEX ( `booking_number` ),INDEX ( `agency` ) ) TYPE = memory;";
    String trunc = "TRUNCATE TABLE `"+tmpTable+"`";
    MySQL.sqlExec(create_query,conn);
    MySQL.sqlExec(trunc,conn);

  • Com.mysql.jdbc.JDBC4Connection suspected memory leak in java

    We have a java application where we are using Bonecp pooling library. Below is how we setup the pooling.
    [code]
    try {
       // setup the connection pool
       BoneCPConfig config = new BoneCPConfig();
      config.setJdbcUrl("jdbc:mysql://**.**.**.**:3306/test1");  config.setUsername("******");
      config.setPassword("*******");  config.setMinConnectionsPerPartition(5);
      config.setMaxConnectionsPerPartition(40);
      config.setPartitionCount(1);
      connectionPool = new BoneCP(config); // setup the connection pool 
       catch (SQLException e) {
      e.printStackTrace(System.out);
    [/code]
    Then for insert and update queries we do this and below we make sure closed the statement.
    [code]
    Statement stmt1 = null;
    stmt1 = dbconn.createStatement();
    String insertQuery3 =........
    count = stmt9.executeUpdate(insertQuery3);
    try{
       if ( stmt1!= null ){  stmt1.close();
       else{
       System.out.println("No stm1 exist");
    }catch(SQLException ex){   System.out.println("SQLException has been caught for stmt1");
    ex.printStackTrace(System.out);
    For select we do this 
    Statement stmt2 = null;
    stmt2 = dbconn.createStatement();
    String selectQuery2= .........
    ResultSet rs2 = stmt2.executeQuery(selectQuery2);
    if(rs2.next())
    try{
       if ( rs2!= null ){  rs2.close();
       }   else{
       System.out.println("No rs2 exist");
       if ( stmt2!= null ){  stmt2.close();
       }   else{
       System.out.println("No stm2 exist");
    }catch(SQLException ex){   System.out.println("SQLException has been caught for stmt2");
    ex.printStackTrace(System.out);
    [/code]
    Thus we have ensured that every resultset and statement is closed immediately after its use. The problem now when we took few sample from MAT is show increasing memory usage as below.
    Sample 1
    [code]
    21 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 11,793,200 (76.19%) bytes.
    Biggest instances:
    com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 958,096 (6.19%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 875,568 (5.66%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 816,048 (5.27%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 754,016 (4.87%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 727,024 (4.70%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 663,872 (4.29%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 618,200 (3.99%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 616,608 (3.98%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 612,544 (3.96%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 598,400 (3.87%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 584,992 (3.78%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 561,224 (3.63%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 531,816 (3.44%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 531,416 (3.43%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 522,184 (3.37%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 482,992 (3.12%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 453,256 (2.93%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 424,656 (2.74%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 187,008 (1.21%) bytes.
    Keywords
    com.mysql.jdbc.JDBC4Connection
    sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0
    file:///C:/Documents%20and%20Settings/ss/Local%20Settings/Temp/report2060944296830228239/pages/18.html# Reference Pattern
    Class Name
    Shallow Heap
    Retained Heap
    Percentage
    class java.lang.Thread @ 0xf0003840
    40
    208
    0.00%
    [/code]
    Sample 2
    [code]
    21 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 13,827,392 (78.27%) bytes.
    Biggest instances:
    com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 1,093,888 (6.19%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 957,888 (5.42%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 916,672 (5.19%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 878,392 (4.97%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 841,136 (4.76%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 758,336 (4.29%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 747,240 (4.23%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 735,712 (4.16%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 700,912 (3.97%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 681,336 (3.86%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 668,080 (3.78%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 658,816 (3.73%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 638,208 (3.61%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 605,376 (3.43%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 582,104 (3.29%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 558,344 (3.16%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 523,952 (2.97%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 508,232 (2.88%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf1603618 - 276,944 (1.57%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 275,288 (1.56%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf148fd70 - 220,536 (1.25%) bytes.
    Keywords
    com.mysql.jdbc.JDBC4Connection
    sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0
    file:///C:/Documents%20and%20Settings/ss/Local%20Settings/Temp/report8548522855535006676/pages/18.html# Reference Pattern
    Class Name
    Shallow Heap
    Retained Heap
    Percentage
    class java.lang.Thread @ 0xf0003840
    40
    208
    0.00%
    [/code]
    Sample 3
    [code]
    21 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 17,339,632 (80.79%) bytes.
    Biggest instances:
    com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 1,228,048 (5.72%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 1,144,056 (5.33%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 1,126,120 (5.25%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 1,074,552 (5.01%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 993,912 (4.63%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 931,512 (4.34%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 930,952 (4.34%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 918,176 (4.28%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 874,512 (4.07%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 846,368 (3.94%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 838,448 (3.91%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 799,184 (3.72%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 791,256 (3.69%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 763,264 (3.56%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 745,088 (3.47%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 710,704 (3.31%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 704,072 (3.28%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 680,400 (3.17%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf1603618 - 458,472 (2.14%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf148fd70 - 390,984 (1.82%) bytes.
    com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 389,552 (1.82%) bytes.
    Keywords
    com.mysql.jdbc.JDBC4Connection
    sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0
    file:///C:/Documents%20and%20Settings/ss/Local%20Settings/Temp/report3656754586920669017/pages/18.html# Reference Pattern
    Class Name
    Shallow Heap
    Retained Heap
    Percentage
    class java.lang.Thread @ 0xf0003840
    40
    208
    0.00%
    [/code]

    Dear Masijade,
                          Actually I was confuse with where to put and not to put the try and catch. Below is how my skeleton of my codes will be looking like. I just put one sample query there. If you notice at the very end finally I already have even now dbconn.close(); which closes the pooling connection. The problem  I am worried now is that incase there is any exception how will it be rollbacked. Because if you notice now I lump all the queries under one big try and catch but with your suggestion I have to do try and catch for each query right?
    [code]
    BoneCP connectionPool = null;
      class ConnectionHandler implements Runnable {
        private Socket receivedSocketConn1;
        ConnectionHandler(Socket receivedSocketConn1) {
          this.receivedSocketConn1=receivedSocketConn1;
        Connection dbconn = null;
        public void run() { // etc
         BufferedWriter writeBuffer = null;
         BufferedReader readBuffer = null;
         String capturedMessage="";
         try{
            dbconn = connectionPool.getConnection();
            dbconn.setAutoCommit(false);
            while ((nextChar=readBuffer.read()) != -1){          
              capturedMessage += (char) nextChar;
              if (nextChar == '*')
               try{
                    //all queries here.
                    try{            
                        Statement stmt1 = null;
                        stmt1 = dbconn.createStatement();
                        try{
                          String updateCommand1 = //query
                          count = stmt1.executeUpdate(updateCommand1);
                        finally{
                          if( stmt1 != null ){
                           stmt1.close();
                        else{
                        System.out.println("stmt1 is null in finally close");
                   catch(SQLException ex){
                     ex.printStackTrace(System.out);
                   dbconn.commit
               catch (SQLException ex){
                    ex.printStackTrace(System.out);
                    try{  
                  dbconn.rollback();
               catch (Exception rollback){  
                  rollback.printStackTrace(System.out);
           catch (Exception e){
               e.printStackTrace(System.out);
               try{  
                  dbconn.rollback();
               catch (Exception rollback){  
                  rollback.printStackTrace(System.out);
           finally
         catch (SocketTimeoutException ex){
               ex.printStackTrace();
         catch (IOException ex){
               ex.printStackTrace();
         catch (Exception ex){
               ex.printStackTrace(System.out);
          finally{
            try{
             if ( dbconn != null ){
               dbconn.close();
             else{
              System.out.println("dbConn is null in finally close");
            catch(SQLException ex){
                ex.printStackTrace();
            try{
              if ( writeBuffer != null ){
                writeBuffer.close();
             else{
              System.out.println("w is null in finally close");
            catch(IOException ex){
                ex.printStackTrace(System.out);
    [/code]

  • Mysql show result-- com.mysql.jdbc.NotImplemented: Feature not implemented

    Hello,
    I have set a database and I am trying to show a simple select.I have this code for example:
    String SQL = "SELECT * FROM DatabaseName.tableName";
                         stmt = (Statement) conn.createStatement();
                         rs = (ResultSet) stmt.executeQuery(SQL);
                         while (rs.next()) {
                            System.out.println(rs.getArray(3));
                         }And all I get is an exception:
    com.mysql.jdbc.NotImplemented: Feature not implemented
    at com.mysql.jdbc.ResultSet.getArray(ResultSet.java:1043)
    Is this right?I have tried other methods but I get the above.How to show the result.
    It is in 3rd column double value.

    Are you guys always this cranky? Who's cranky? It's important for the integrity of these forums that misinformation isn't left lying around uncorrected. If that makes you cranky, try elsewhere where the standards may not be so high.
    I posted something that works, now is it exactly as whatever getArray does?No.
    Probably not.Just a minute. You said here that 'the work around code' is something like this, and here that 'it actually is the same result'. You were mistaken. Twice. You are now in the process of changing your mind. Let me help you. It is definitely not exactly what getArray() does. Not even close. Completely different. getArray() gets an array directly from the database from a single column in the current row in the result set. Your code constructs an array from a single column across all rows in the result set. There is no comparison.
    What's wrong with helping outWhat's wrong with getting it right? What's wrong with pointing out an error? What's wrong with admitting when you're mistaken? What's wrong with alerting the OP not to mention all future readers of this thread that it contains misinformation? What's wrong with you finding out that you were wrong?
    and posting what you think it should say
    rather than just being negative?As a matter of fact nobody was 'just negative'. I pointed out exactly what the difference between your code and getArray() is. But by 'negative' do you mean pointing out that you were wrong? Nothing wrong with that.

  • Using mysql jdbc driver leads to exception

    I try to use com.mysql.jdbc.Driver with JDeveloper 9i business components. The following is the code I use to test if mysql driver works with business components:
    package test;
    import oracle.jbo.*;
    import java.util.Hashtable;
    import javax.naming.*;
    public class Test { 
    public static void main(String[] args) {   
    final String amName = "test.TestModule";
    final String voName = "test.TesttableView";
    final String userName = "some_user";
    final String password = "some_password";
    final String connStr = "jdbc:mysql://localhost:3306/test";
    System.setProperty("jdbc.drivers", "com.mysql.jdbc.Driver");
    Hashtable env = new Hashtable(2);
    env.put(Context.INITIAL_CONTEXT_FACTORY, JboContext.JBO_CONTEXT_FACTORY);
    env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
    ApplicationModule appMod = null;
    try {     
    javax.naming.Context ic = new InitialContext(env);
    ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(amName);
    appMod = home.create();
    java.util.Properties props = new java.util.Properties();
    props.put("user",userName);
    props.put("password",password);
    props.put("defaultRowPrefetch","15");
    appMod.getTransaction().connect(connStr, props);
    } catch(Exception e) {     
    e.printStackTrace();
    ViewObject vo = appMod.createViewObject("vo", voName);
    Row r = vo.first();
    r.setAttribute("Testcolumn", "Some text");
    System.out.println("vo before AppMod post " + r.getAttribute("Testcolumn"));
    try {   
    appMod.getTransaction().commit();
    System.out.println("Commit succeeded.");
    } catch (oracle.jbo.JboException e) {   
    System.out.println("Commit failed. " + e);
    r = vo.first();
    System.out.println("vo after AppMod commit " + r.getAttribute("Testcolumn"));
    Everything works fine until ViewObject.first() is called, then the following exception is thrown:
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.ClassCastException, msg=com.mysql.jdbc.PreparedStatement
         void oracle.jbo.JboException.<init>(java.lang.Throwable)
              JboException.java:344
         oracle.jbo.Row oracle.jbo.server.ViewRowSetIteratorImpl.first()
              ViewRowSetIteratorImpl.java:1156
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.first()
              ViewRowSetImpl.java:2240
         oracle.jbo.Row oracle.jbo.server.ViewObjectImpl.first()
              ViewObjectImpl.java:4345
         void test.Test.main(java.lang.String[])
              Test.java:32
    ## Detail 0 ##
    java.lang.ClassCastException: com.mysql.jdbc.PreparedStatement
         void oracle.jbo.server.OracleSQLBuilderImpl.doStatementSetRowPrefetch(java.sql.Statement, int)
              OracleSQLBuilderImpl.java:894
         java.sql.PreparedStatement oracle.jbo.server.DBTransactionImpl.createPreparedStatement(java.lang.String, int)
              DBTransactionImpl.java:2695
         java.sql.PreparedStatement oracle.jbo.server.DBTransactionImpl2.createPreparedStatement(java.lang.String, int)
              DBTransactionImpl2.java:418
         java.sql.PreparedStatement oracle.jbo.server.DBTransactionImpl.createReUsePreparedStatement(java.lang.String, int)
              DBTransactionImpl.java:3467
         java.sql.PreparedStatement oracle.jbo.server.ViewObjectImpl.getPreparedStatement(int, boolean[])
              ViewObjectImpl.java:6496
         void oracle.jbo.server.QueryCollection.executeQuery(java.lang.Object[], int)
              QueryCollection.java:483
         void oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(java.lang.Object, java.lang.Object[], int)
              ViewObjectImpl.java:2600
         void oracle.jbo.server.ViewRowSetImpl.execute(boolean, boolean)
              ViewRowSetImpl.java:521
         void oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed()
              ViewRowSetIteratorImpl.java:2197
         oracle.jbo.Row oracle.jbo.server.ViewRowSetIteratorImpl.first()
              ViewRowSetIteratorImpl.java:1141
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.first()
              ViewRowSetImpl.java:2240
         oracle.jbo.Row oracle.jbo.server.ViewObjectImpl.first()
              ViewObjectImpl.java:4345
         void test.Test.main(java.lang.String[])
              Test.java:32
    Exception in thread main.
    Is there anyone who would be able to help me with this problem?
    Thank you in advance!

    Use
    Class.forName("com.mysql.jdbc.Driver");Is the MySQL JDBC JAR file listed in project path.?

Maybe you are looking for

  • Stuck at 21% of the Dreamweaver CS 5.5 installer

    My situation before i had troubles: - CS3 Web Premium installed; - Dreamweaver CS5.5 upgrade installed over this; - I tried installing the latest mobile development update for DW CS5.5 but kept getting the U44M1P7 error so i followed this guide: http

  • How to Use Temporary table on report builder

    Hi community! Well, i'm trying to build a temporary table based report in Oracle Report Builder. in "After Parameter Form Trigger" I've placed a stored procedure that populate a temporary table and I've based my report on it. The problem is Report sh

  • How to use JAXB generated classes with SOAP

    hello, I have a library of JAXB generated classes for my web service. There is a Java class for each web method defined in my schema. For example, my getLocation method is mapped to GetLocation.class. However my web service is SOAP based, so I am hav

  • Security settings for download

    i am trying to download the latest itunes and i keep getting the message that my security settings wont let me download the software. i have checked everything i can think of but it still wont let me. please help.

  • Connecting the V-Studio 100 controller as GarageBand interface

    I am trying to connect the Cakewalk (Roland) V-Studio 100 controller as an interface to GarageBand.  In the Sound Pref's I see that the Mac is receiving audio signal from the V-Studio but GarageBand is not getting it.  I did set up the GarageBand Pre