The Artima Developer Community
Sponsored Link

Java Answers Forum
JAva Application and JDBC Oracle 9i connection problem

4 replies on 1 page. Most recent reply: Aug 27, 2005 1:17 AM by Subodh Rawat

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
borce ivanovski

Posts: 3
Nickname: borce
Registered: Apr, 2005

JAva Application and JDBC Oracle 9i connection problem Posted: May 8, 2005 4:32 PM
Reply to this message Reply
Advertisement
HI everyone,

I am trying to make a connection with a Oracle 9i server. I have a home network of three Pcs, with ip 192.168.1.2, 1.3. and 1.4 respectivly. I have the oracle server installes on the 1.3 ip and I am trying to connect from the 1.2 PC to the Oracle server but it gives me some problems. I am trying through the SQL PlusWorkshear and it works. I can work on the database, but through the Java Application created I can not. This is the code from the application:

import java.sql.*;
public class ConnectionThin_1
{

/** Creates a new instance of Connection */
public ConnectionThin_1() {
}
public static void main(String[] args)
{
// System.out.println("PROBLEM");
//int i;
Connection conn = null;

// register jdbc driver
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
// in order to use Oracle thin/oci driver

} catch(ClassNotFoundException e) {
System.out.println(e);
}

// connect to DB
try{
// DriverManager.registerDriver(Driver OracleDriver);
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:katarina","scott","tig er");
System.out.println("PROBLEM");
// System.out.println(conn);
// thin: driver
// @127.0.0.1 for local connection. @xxx.xxx.xxx.xxx for global
// 1521: port number. This should be match to Oracle network port.
// datacafe: SID of Oracle database
// scott: username of Oracle database
// tiger: password of Oracle database

} catch(SQLException se) {
System.out.println(se);
System.out.println("connection is successful!!!");
}


try{
String selectSQL = "select * from student";
ResultSet rset = conn.createStatement().executeQuery(selectSQL);

while(rset.next()){
System.out.println("studentName: " + rset.getString(1) + " studentSurname: " +
rset.getString(2));
}

conn.createStatement().close();
} catch(SQLException se) {
System.out.println(se);
}
}



}


And it gives me this error:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.sql.SQLException: No suitable driver
connection is successful!!!
java.lang.NullPointerException
at ConnectionThin_1.main(ConnectionThin_1.java:56)
Exception in thread "main"

Please anyone help me.

Thanks in advance.


Subodh Rawat

Posts: 9
Nickname: zeon
Registered: May, 2005

Re: JAva Application and JDBC Oracle 9i connection problem Posted: May 11, 2005 2:55 PM
Reply to this message Reply
Set the classes12.zip file in your classpath. Also remove the system.out from the exception or atleast chenge the text. Currently, it says connection is successful, which is wrong.

bannigol srinivas

Posts: 1
Nickname: bannigol
Registered: May, 2005

Re: JAva Application and JDBC Oracle 9i connection problem Posted: May 30, 2005 10:32 PM
Reply to this message Reply
Please include port number in the connection statement i.e :


conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:katarina","scott" ,"tig er");

Deepesh

Posts: 1
Nickname: nellutla
Registered: Aug, 2005

Re: JAva Application and JDBC Oracle 9i connection problem Posted: Aug 25, 2005 10:52 AM
Reply to this message Reply
hi,
as mentioned in your reply to add the classes12.zip in classpath..u mean in which folder..like i have only j2sdk1.4 installed on my local machine and oracle 9i on remote server..i have been trying to include the zip file in bin,jre\lib,jre\bin folders and set the classpath , but could not get the answer..do u have any suggestion for the problem..if so please send me the path..its very urgent ..

thanks

Subodh Rawat

Posts: 9
Nickname: zeon
Registered: May, 2005

Re: JAva Application and JDBC Oracle 9i connection problem Posted: Aug 27, 2005 1:17 AM
Reply to this message Reply
You will find this zip file here ...

http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc817.html
or here
http://www.google.com/search?hl=en&q=classes12.zip

add to your classpath so that it picks up the classes from this zip file ..

Flat View: This topic has 4 replies on 1 page
Topic: java Previous Topic   Next Topic Topic: NetBeans GUI Question

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use