Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help reuired in jdbc connection

 
felix thomas
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic