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!

Oracle Thin Client

843854Oct 5 2001 — edited Oct 10 2001
New to java. I have the book "JDBC API Tutorial and Reference". Using jdbc odbc bridge was no problem. Now I am going back and trying to use the Oracle Thin Client. The code compiles, but I get the following exception when executing it:

D:\TutorialDB>java CreateCoffees
SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=1352949
76)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

I have checked and rechecked the username and passowrd.
Below is the code for this example with my changes.

import java.sql.*;

public class CreateCoffees {

public static void main(String args[]) throws SQLException {

//ALF added this for oracle thin client driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

//ALF commented out the following as not using jdbc odbc bridge
//String url = "jdbc:odbc:Tutorial";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";

Statement stmt;

//ALF commented out the following as now using different driver

//try {
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

//} catch(java.lang.ClassNotFoundException e) {
// System.err.print("ClassNotFound: ");
// System.err.println(e.getMessage());
//}
//
try {
con = DriverManager.getConnection("jdbc:oracle:thin:@W2RZ1NXG01:1530:java","Admin","apassword");

stmt = con.createStatement();
stmt.executeUpdate(createString);

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());


}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2001
Added on Oct 5 2001
2 comments
393 views