Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Neon Shadow JDBC driver woes!

843854May 5 2005 — edited May 5 2005
I've been trying querying a DB2 database from a simple JDBC code using Neon Shadow driver since yesterday with different combinations and I even tried referring to an article
http://dev2dev.bea.com/pub/a/2004/01/Mills.html
But I just can't get it working. It's always showing me an error message like
java.sql.SQLException: [NEON][SCODBCTS DLL]Dynamic-to-static initialization failed
        at com.neon.jdbc.SQLError.Check(SQLError.java:126)
        at com.neon.jdbc.ProxyLocal.SQLDriverConnect(ProxyLocal.java:719)
        at com.neon.jdbc.Connection.<init>(Connection.java:91)
        at com.neon.jdbc.Driver.connect(Driver.java:183)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:146)
        at TestNeonDb2.main(TestNeonDb2.java:35)
Here's my code:
// DB2 Test program using Neon Shadow JDBC driver - AC

import java.util.*;
import java.sql.*;

public class TestNeonDb2 {

    public static final String DRIVER_CLASS  = "com.neon.jdbc.Driver";
    public static final String DATABASE_URL  = "jdbc:neon:UNKNOWN"; // Neon DSN
    public static final String DBUSER        = "ANNIE001";
    public static final String DBPASS        = "ANNIE001";
    public static final String DBSERVER      = "mf000000";
    public static final String DBPORT        = "1200";
    public static final String DATABASE      = "DB2TEST";

    public static void main(String[] args) {
        Connection con           = null;
        PreparedStatement pstmt  = null;
        ResultSet rs             = null;

        try {
            Class.forName(DRIVER_CLASS);
            System.out.println("Driver Class loaded -- create connection.");

            System.out.println("Creating connection...");
            con = DriverManager.getConnection(DATABASE_URL, getProperties());
            System.out.println("Connection created " +con);

            // String sql = "SELECT ro_cd, sta_no FROM TBLTMP01 WHERE car_type = ?";
            // The commented query works and returns the result properly.
            String sql = "SELECT count(*) from TBLTMP01";
            // This one doesn't :(
            // It returns an error message like "Dynamic query cannot be converted to static SQL"
            pstmt       = con.prepareStatement(sql);
            // pstmt.setString(1, "FORD");
            rs          = pstmt.executeQuery();

            while(rs.next()) {
                System.out.println("Result = " +rs.getString(1));
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            close(rs);
            close(pstmt);
            close(con);
        }
    }

    public static Properties getProperties() {
        Properties properties = new Properties();
        properties.put("user", DBUSER);
        properties.put("password", DBPASS);
        return properties;
    }

    public static void close(Connection connection) {
        try {
            if(connection != null && !connection.isClosed())  connection.close();
        } catch (Exception exception) {
            System.out.println("Error closing connection... ");
            exception.printStackTrace();
        }
    }

    public static void close(Statement statement) {
        try {
            if(statement != null)  statement.close();
        } catch (Exception exception) {
            System.out.println("Error closing statement... ");
            exception.printStackTrace();
        }
    }

    public static void close(ResultSet resultset) {
        try {
            if(resultset != null)  resultset.close();
        } catch (Exception exception) {
            System.out.println("Error closing resultset... ");
            exception.printStackTrace();
        }
    }

}
Can anyone help? DOes anyone know the solution with this problem. My head is all spinning.

Thanks
***Annie***
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2005
Added on May 5 2005
7 comments
1,517 views