How to download JdbcOdbcDriver from java home page

Hi I want download JdbcOdbcDriver from java home pageBut I can't find the product(I use windows 2000)Please tell me how to do or detail url.Thanks a lot David
[215 byte] By [dong33] at [2007-9-26 6:45:49]
# 1
It's part of the JDK.You should have it already.
Hartmut at 2007-7-1 16:09:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Yes I already have JDK 2.I want use JDBC-ODBC Bridge to connect systen DNS.
dong33 at 2007-7-1 16:09:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Ok, for short:

All JDBC commands in try-blocks - for the best use one own try-catch for each command:// Load driver class

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

// Connect - DSN is "myDSN", user is "myUser", password is "myPW"

Connection Con = DriverManager.getConnection(

"jdbc:odbc:myDSN", "myUser", "myPW" );

// Execute a Select

Statement st = Con.createStatement();

ResultSet rs = st.executeQuery( "select id, name from tab where id < 100" );

// Loop over all records

while( rs.next() )

{

// Read actual record

int id = rs.getInt( 1 );

String name = rs.getString( 2 );

// Test output

System.println( "id = " + id );

System.println( "name = '" + name + "'" );

}

// next select

rs = st.executeQuery( "select ..." );

...

// recommended: close statement

st.close();

// Disconnect

con.close();

If you catch the exceptions ascatch( SQLException e )

, you can print out more informations like DB error code etc.

Look at the methods of SQLException.

Hartmut at 2007-7-1 16:09:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Hi,

Could you tell me what is the difference between :

your proposal :

// Load driver classClass.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );// Connect - DSN is "myDSN", user is "myUser", password is "myPW"Connection Con = DriverManager.getConnection( "jdbc:odbc:myDSN", "myUser", "myPW" );

and this proposal :

this servlet FindNames ...

String queryString = "select FIRST_NAME, LAST_NAME from EMPLOYEE_INFO where FIRST_NAME like '" +

f_name +

"%' and LAST_NAME like '" +

l_name +

"%'";

try

{

///Build and execute query

ODBCConnect SQL = new ODBCConnect();

ResultSet rset;

SQL.setDSN("Activity3");

SQL.setSQLString(queryString);

rset = SQL.select();

.... calling this ODBCConnect class, with this method:

public static ResultSet select()

throws SQLException

{

DriverManager.registerDriver(new "sun.jdbc.odbc.JdbcOdbcDriver");

conn = DriverManager.getConnection (DBName, "training", "training");

stmt = conn.createStatement();

return stmt.executeQuery(queryString);

}

Question :

- is

DriverManager.registerDriver(new "sun.jdbc.odbc.JdbcOdbcDriver");

equal to

ClassForName("sun.jdbc.odbc.JdbcOdbcDriver")

?

Thanks for your help.

Regards

Hugues

hugues72d at 2007-7-1 16:09:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Hi,look at the Java API docs, intro for class DriverManager.This should be clear.If not, feel free to ask again!
Hartmut at 2007-7-1 16:09:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...