View Full Version : cannot connect to database with jdbc:odbc
mchristmas
01-29-03, 03:01
| Hi everyone,
I'm trying to connect oracle database running on win 2000 workstation. The program used is was this
import java.sql.*;
public class OnlineStoreConnection
{
public static void main(String a[])
{
String data ="jdbc:odbc:student";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection(
"data", "student", "student");
Statement st = con.createStatement();
ResultSet rec = st.executeQuery("SELECT FIRSTNAME, LASTNAME"
+ "FROM CUSTOMER" + "WHERE CUST_ID=101");
System.out.println("CUST_ID\tFISTNAME\tLASTNAME");
while(rec.next())
{
System.out.println(rec.getString(1) + "\t" +
rec.getString(2) + "\t\t" +
rec.getString(3));
}
st.close();
} catch(SQLException s)
{
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " "+ s.getSQLState());
}
catch(Exception e)
{
System.out.println("Error: " + e.toString() + e.getMessage());
}
}
}
however i get an error that says java.sqlException no sutable driver 08001
thank you in advance |
GadgetGuru
02-21-03, 08:40
I would expect that the JDBC-ODBC Bridge Driver isn't in your classpath
| You've got the wrong database driver , try this
String data = "jdbc:oracle:student"
Class.forName ("oracle.jdbc.driver.OracleDriver")
Originally posted by mchristmas
Hi everyone,
I'm trying to connect oracle database running on win 2000 workstation. The program used is was this
import java.sql.*;
public class OnlineStoreConnection
{
public static void main(String a[])
{
String data ="jdbc:odbc:student";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection(
"data", "student", "student");
Statement st = con.createStatement();
ResultSet rec = st.executeQuery("SELECT FIRSTNAME, LASTNAME"
+ "FROM CUSTOMER" + "WHERE CUST_ID=101");
System.out.println("CUST_ID\tFISTNAME\tLASTNAME");
while(rec.next())
{
System.out.println(rec.getString(1) + "\t" +
rec.getString(2) + "\t\t" +
rec.getString(3));
}
st.close();
} catch(SQLException s)
{
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " "+ s.getSQLState());
}
catch(Exception e)
{
System.out.println("Error: " + e.toString() + e.getMessage());
}
}
}
however i get an error that says java.sqlException no sutable driver 08001
thank you in advance |
vBulletin v3.5.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.