Regarding JDBC-ODBC problem

hi,

i am having my oracle8.1.5 server is running on Windows2000 server and Service Pack 2. i have created the service and also i have created the DSN. For creating the DSN i am using Oracle ODBC Driver 8.01.05.

And i am trying to connect the database through my java program(JDBC). This application(java program) also running on same machine.

i am having the code like that

import java.io.*;

import java.sql.*;

class ClsDBTest

{

private Connection objCon ;

public ClsDBTest()

{

}

public boolean blnConDb()

{

boolean blnRet = false;

try

{

Class.forName ("oracle.jdbc.driver.OracleDriver");

objCon = DriverManager.getConnection("jdbc:odbc:dsnTpcw","scott","tiger");

blnRet = true ;

}

catch(Exception objEx)

{

System.out.println("Connection Failed: " + objEx.getMessage());

}

return blnRet;

}

public static void main(String[] args)

{

ClsDBTest objDB = new ClsDBTest();

boolean blnRet ;

blnRet = objDB.blnConDb();

System.out.println("Connection Result : " + blnRet ) ;

}

}

this code is not giving any error also. its not connected with the database.

pls can any one give the solution for this.

NOTE: if i am using the "thin" driver then its working fine.

Regards,

Sudakar.K

[1411 byte] By [sudaindiaa] at [2007-9-27 11:20:47]
# 1

> hi,

>

> i am having my oracle8.1.5 server is running on

> Windows2000 server and Service Pack 2. i have created

> the service and also i have created the DSN. For

> creating the DSN i am using Oracle ODBC Driver

> 8.01.05.

>

> And i am trying to connect the database through my

> java program(JDBC). This application(java program)

> also running on same machine.

>

> i am having the code like that

>

> import java.io.*;

> import java.sql.*;

>

> class ClsDBTest

> {

> private Connection objCon ;

> public ClsDBTest()

> {

> }

>

> public boolean blnConDb()

> {

> boolean blnRet = false;

> try

> {

<b>

// CHECK OUT THIS IS THIN DRIVER SPECIFIC AND NOT JDBC ODBC...............

> Class.forName ("oracle.jdbc.driver.OracleDriver");

//..............................................

> objCon =

> DriverManager.getConnection("jdbc:odbc:dsnTpcw","scott

> ,"tiger");

> blnRet = true ;

> }

> catch(Exception objEx)

> {

> System.out.println("Connection Failed: " +

> + objEx.getMessage());

>

> }

>

> return blnRet;

> }

>

> public static void main(String[] args)

> {

>

> ClsDBTest objDB = new ClsDBTest();

> boolean blnRet ;

> blnRet = objDB.blnConDb();

>

>

> System.out.println("Connection Result : " + blnRet )

> ) ;

> }

> }

>

>

> this code is not giving any error also. its not

> connected with the database.

> pls can any one give the solution for this.

>

>

> NOTE: if i am using the "thin" driver then its working

> fine.

>

> Regards,

> Sudakar.K

You did not load the jdbc-odbc driver.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

This should solve the problem,

Cheers,

Sekar

rajaboobalana at 2007-7-9 5:58:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...