Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection using eclipse ide

 
piyush kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am new to this forum, i am learning j2ee and there is something going wrong with my codes.. I am posting the code here.

import java.sql.*;

public class TestConnection {

/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
con = ConMgmt.getConnection();
System.out.println("Connection eastablished successfully");
stmt = con.createStatement();
rs = stmt.executeQuery("select ename from emp");

while(rs.next())
{
String Name = rs.getString("ename");
System.out.println("Name: " + Name);
}
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
System.out.println("ResultSet closed");
}
if(stmt != null)
{
stmt.close();
System.out.println("Statement closed");
}

if(con != null)
{
con.close();
System.out.println("Connection closed");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}

when I am running this code it is giving rsult as

0
Connection eastablished successfully
java.sql.SQLException: ORA-00600: internal error code, arguments: [ttcgcshnd-1], [0], [], [], [], [], [], []

Statement closed
Connection closed

and not getting the proper output.I had debugged the program and the rsultset still remains null.It is not changing to the desired value.I am using eclipse as the ide oracle 9i as the database source and jdk1.5.
Plzzzzz help ???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35266
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piyush,
Does it work if you query the database without going through Java?

Are there any other error codes? This site implies there is a numeric argument that comes with that exception.

You might try e.printStackTrace() for more details on the exception.
 
piyush kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes sir,
the query works fine when executed without java..and when i tried using e.printStackTrace(); it gives me the following result....

0
Connection eastablished successfully
java.sql.SQLException: ORA-00600: internal error code, arguments: [ttcgcshnd-1], [0], [], [], [], [], [], []

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1681)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:538)at TestConnection.main(TestConnection.java:20)
Statement closed
Connection closed

so what does this mean..i am trying to find out..
 
piyush kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sir, thank you for your reply. My problem got solved by including the ojdbc14.jar file into the classpath and removing the class12.jar from he classpath. I dont know what has happened and why is this so. I think this ojdbc14.jar is the oracle 10g driver for jdbc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic