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
posted
0
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
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 ]