• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JDBC Problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
this is driving me crazy; i'm trying to retrieve records from a local oracle database (on my laptop) - the oracle driver gets registered, it connects to the database BUT when i try to executeQuery() with a valid SQL it throws the following exception;
Exception occurred during event dispatching:
java.lang.NullPointerException at Retrieve.retrieve(Retrieve.java:103)...........
i have also tried using an Access db but it throws the same exception. what am i missing ???
NOTE : using jdk 1.3 and oracle 7.3.4
any help will be appreciated.
thanx
go java !!
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friend!
The problem may be with undefined resultset.After the connection follow the given below lines:
Statement st = cn.createStatement()
ResultSet rs1 = st.executeQuery("select * from *table name*");
while(rs.next())
{System.out.println(rs.getInt("field name"));
}
I hope this will solve the problem.
regards,
Atonu Bhowmik
[This message has been edited by Paul Wheaton (edited November 13, 2000).]
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code works for me.
JDK 1.3 / JDBC ver 1.0 / NT / Oracle 7.3.4 on a unix box.
Hope this helps...
<code>
import java.sql.*;
public class CreateCoffees {
public static void main(String args[]) {

String url = "jdbc racle:thin:@hostname:1521:sid";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}

catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url "USERID", "PASSWORD");
stmt = con.createStatement(); stmt.executeUpdate(createString);
stmt.close();
con.close();
}
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
} // end of main
} // end of class
</code>

[This message has been edited by Monty Ireland (edited November 08, 2000).]
[This message has been edited by Monty Ireland (edited November 08, 2000).]
[This message has been edited by Monty Ireland (edited November 09, 2000).]
 
Trailboss
Posts: 24042
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgive my edits above, but the angle brackets in the message were being interpretted as html and made the whole page unviewable.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Ranch has a naming policy, described here and "iamontheinet" is not a valid name. Please choose one which meets the requirements.
Thanks.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys, thanx for your responses.
frank, i have changed my username.
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
reply
    Bookmark Topic Watch Topic
  • New Topic