• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC-ORACLE: Why same code work at local machine but not remote client?

 
Allen Chan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//the code are as following, it works fine on server local machine but not on the client, I have double checked the javapath/jre/ext and I have those zip files for oracle, but the errors still says class not found, any ideas? Thanks
import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.ResultSet ;
import java.sql.Statement ;
class JavaOraConn
{
public static void main (String s[])
{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch (ClassNotFoundException e) {
System.err.println (e) ;
System.exit (-1) ;
}
try {
// open connection to database
Connection connection = DriverManager.getConnection(
"jdbc racle:thin:@ServerIP:1521 ra9i",
"scott", // ## fill in User here
"tiger" // ## fill in Password here
);
// build query
String query = "SELECT * From emp" ;
// execute query
Statement statement = connection.createStatement () ;
ResultSet rs = statement.executeQuery (query) ;
System.out.println ("Test:") ;
while ( rs.next () )
System.out.println (rs.getInt ("empno") + " | " +
rs.getString ("EName") + " | " +
rs.getInt ("MGR")) ;
connection.close () ;
}
catch (java.sql.SQLException e) {
System.err.println (e) ;
System.exit (-1) ;

}
}
}
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
triple check your classpath on the remote machine. If you still think it is OK, then post your classpath of the remote machine here and post the actual path of the classes12.zip files on the remote machine. Maybe we can see a subtle error that you may have overlooked.
Jamie
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jamie Robertson:
triple check your classpath on the remote machine. If you still think it is OK, then post your classpath of the remote machine here and post the actual path of the classes12.zip files on the remote machine. Maybe we can see a subtle error that you may have overlooked.
Jamie

One quick way to check your classpath is to use the javap utility. Try this...
javap oracle.jdbc.driver.OracleDriver
If this works (it prints out a summary of all the methods/fields of the class), then your classpath is correct. If not, contact Houston because you've got a problem! :-)
 
Allen Chan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try javap oracle.jdbc.driver.OracleDriver and it says class not found. Now I am got confused, since I could compile the class and run, what happen?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic