GeeCON Prague 2014*
The moose likes JDBC and the fly likes JDBC connection using eclipse ide Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC connection using eclipse ide" Watch "JDBC connection using eclipse ide" New topic
Author

JDBC connection using eclipse ide

piyush kumar
Greenhorn

Joined: Feb 01, 2007
Posts: 20
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

Joined: May 26, 2003
Posts: 30580
    
154

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
piyush kumar
Greenhorn

Joined: Feb 01, 2007
Posts: 20
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

Joined: Feb 01, 2007
Posts: 20
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.
 
GeeCON Prague 2014
 
subject: JDBC connection using eclipse ide