|
Subject:
|
connecting to oracle
|
|
Posted By:
|
amcp2002
|
Post Date:
|
8/6/2003 10:01:46 PM
|
hi,
i'm fairly new to java. i'm trying to connect to an oracle database but it's giving me the following error:
C:\JSPTests>java RPASelect ClassNotFoundException: oracle.jdbc.driver.OracleDriver SQLException: No suitable driver
i have j2sdk1.4 installed on my Windows NT 2000. i don't have any oracle installed on my machine. i'm basically connected to our office network. i'm not the oracle admin. i also read about the classes111.zip but i don't know if it applies to me since i'm not running oracle on my local machine. i also trying running the same code connecting to MS Access (changing what i need to change) and i get results. however, when i try modify the program to connect to oracle. i get the message above. what am i doing wrong? thanks for any help. i'm also using "thin".
here's the code i'm using:
import java.sql.*; import java.util.*; import java.awt.*;
public class RPASelect { public static void main(String args[]) { String url = "jdbc:oracle:thin:@nnnn:nnn:nnnnn"; Connection con; String queryString; queryString = "select * from RPA_RESOURCE where RPA_RESOURCE.COLCD = '**'";
Statement stmt; ResultSet rs;
try { DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); //Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("JDBC driver loaded"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); }
try { con = DriverManager.getConnection(url, "myID", "myPass"); stmt = con.createStatement(); rs = stmt.executeQuery(queryString); while (rs.next()) out.println(rs.getString(1)); stmt.close(); con.close(); } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } } }
I've read some people said I need to download classes111.zip or jbdc14.jar from www.oracle.com. Is this applicable to my setup which I describe above? If in fact I need it, where to I install the file on my PC? Which one to I really need (classes111.zip or jbdc14.jar)? I'm getting confused. Please advise. Thank you in advance.
Paul
|
|
Reply By:
|
amcp2002
|
Reply Date:
|
8/12/2003 12:08:56 PM
|
got this one to work. i downloaded jbdc14.jar and modified my classpath..
|
|
Reply By:
|
yasir_lahham
|
Reply Date:
|
9/20/2003 5:17:52 PM
|
I'm using classes11.zip and it's working perfectly, just download it, and modify your classpath in the system environment to include it (for example c:\classes.zip), or if you're doing a web-application put it in the "WEB-INF/lib" directory and thats all, notice that in some cases you might have to rename the file to classes.jar.
MHD Yasir Al-lahham
|