It's not a secret anymore!*
The moose likes JDBC and the fly likes help reuired in jdbc connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "help reuired in jdbc connection" Watch "help reuired in jdbc connection" New topic
Author

help reuired in jdbc connection

felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
hi,
i am using oracle 8.1.5 fo windows

but i am getting this error whil runing my code
Employee.java:21: package no suitable driver exists.
the code is given below
import java.sql.*;
class Test{
public static void main (String args []) throws SQLException {
// Load the Oracle JDBC driver DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection ("jdbc racle", "scott", "tiger"); System.out.println("connection"); conn.close(); } }

I have set the classpath also to the driver
h:\Oracle\Ora81\jdbc\lib\classes112.zip
but not the path.
could any one help me out.
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi,
The code is ok...anyway here's a test code, which u may use, if needed...
Also I think the zip file should be classes111.zip and not classes112.zip.
Properties x = new Properties();
x.put("user","custview");
x.put("password","custview");
try{
String url= "jdbc racle:thin:@8.95.0.234:1521:IFXT";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, x);
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from news");
while(rs.next())
{
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
}catch(Exception e){
System.out.println(e);
}

Mahesh
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

you are missing information in your getConnection URL. see this page for complete details. The skinny of it is that "jdbcracle" is only partially correct. The specs say you need to have "jdbcracle:thin:<host_name>:<port_number>:<database_name(SID)>" most of which you are missing
you will encounter this problem after your classpath problem. For the classpath problem, your drivers will be either classes12.zip(most likely) or classes111.zip. So you should change your classpath to reflect this.
Jamie
[ April 29, 2002: Message edited by: Jamie Robertson ]
[ April 29, 2002: Message edited by: Jamie Robertson ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: help reuired in jdbc connection