Forums Register Login

JDBC Problem

+Pie Number of slices to send: Send
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 !!
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
Forgive my edits above, but the angle brackets in the message were being interpretted as html and made the whole page unviewable.
+Pie Number of slices to send: Send
The Java Ranch has a naming policy, described here and "iamontheinet" is not a valid name. Please choose one which meets the requirements.
Thanks.
+Pie Number of slices to send: Send
guys, thanx for your responses.
frank, i have changed my username.
+Pie Number of slices to send: Send
Thank you.
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 800 times.
Similar Threads
Type 4
XSU
Timestamp with Timezone problem while retrieving from Oracle db
How to know whether a particular row exists in table
SQL task : memory leak , too many open connection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:16:47.