Sopolin
Sopolin

Reputation: 576

JDBC THIN Oracle with Java6

I have a problem with JDBC Thin in Oracle 11g with NetBeans V6.7.1. I don't know how to configure it. I have already set classpath of ojdbc6.jar and orai18n.jar. But I still can't run this example in NetBeans:

import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
class JDBCVersion
{
    public static void main (String args[]) throws SQLException
    {
        OracleDataSource ods = new OracleDataSource();
        ods.setURL("jdbc:oracle:thin:easycash/oracle@oracle:1521/validus");
        Connection conn = ods.getConnection();
        // Create Oracle DatabaseMetaData object
        DatabaseMetaData meta = conn.getMetaData();
        // gets driver info:
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
    }
}

Could anyone help finish my work?

Thanks, Sopolin

Upvotes: 1

Views: 4083

Answers (2)

user800014
user800014

Reputation:

If the error is:

java.lang.ClassNotFoundException: oracle.dms.console.DMSConsole

You will need the dms.jar that comes with the Oracle Database.

In my case this jar is located inside lib folder of OC4J.

This only happen when you use ojdbc*dms.jar. From the JDBC download site:

"Same as ojdbc6.jar, except that it contains instrumentation to support DMS and limited java.util.logging calls."

Upvotes: 1

user213785
user213785

Reputation:

Try this:

class JDBCVersion
{
    public static void main (String args[]) throws SQLException
    {
        OracleDataSource ods = new OracleDataSource();
        ods.setURL("jdbc:oracle:thin:@oracle:1521:validus");
        ods.setUser("easycash");
        ods.setPassword("oracle");
        Connection conn = ods.getConnection();
        // Create Oracle DatabaseMetaData object
        DatabaseMetaData meta = conn.getMetaData();
        // gets driver info:
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
    }
}

Did you have the oracle-dms.jar in your Classpath?

Upvotes: 0

Related Questions