This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JDBC connection using eclipse ide

 
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 ???
 
author & internet detective
Posts: 39396
763
Eclipse IDE VI Editor Java
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!