jdbc with oracle "run time error"!!!

I'm trying to connect to Oracle using jdbc.

this is the simple code for my program, I'm getting run time error

"memeory couldn't be read".

import java.sql.*;

class MyCon{

public static final String JDBC_URL = new String("jdbc:oracle:oci8:@BhDb1onlocalhost");

public static final String USERNAME = new String("scott");

public static final String PASSWORD = new String("tiger");

public static void main(String args[])

{

try {

MyCon myob = new MyCon();

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

Connection con = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);

Statement stm = con.createStatement();

ResultSet rs = stm.executeQuery("Select * from Providers");

ResultSetMetaData rsmd = rs.getMetaData();

while(rs.next()) {

for(int count=1;count<=rsmd.getColumnCount();count++) {

System.out.println(rs.getString(count));

}

}

} catch(Exception e) {

System.out.println("caught:"+e);

}

}

}

I'm using windowsNT 4.0

jdk1.2.2

oracle 8.1.5

classess111.zip is in my classpath

thanx in advance.

[1248 byte] By [javagrrl_in] at [2007-9-26 1:30:10]
# 1

I'm not sure about the error you're getting, but you might want to try a few things:

1) Try the thin driver instead of the oci driver. The thin driver is all java, while the oci requires an Oracle client installation (which might be why your getting the memory error). I think the only programming difference is the URL, so if you need to switch later it should be relatively easy.

2) Instead of DriverManager.registerDriver(), tryClass.forName("oracle.jdbc.driver.OracleDriver").newInstance();

3) I know this sounds bad, but try throwing some print statements in to see how far you're getting.

Here a quick sample. And remember to include the classes111.zip in your classpath.

import java.sql.*;

public class OracleTest {

public static void main(String args[]) {

try {

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

Connection c = DriverManager.getConnection(

"jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");

System.out.println("Got connection.");

c.close();

} catch (Exception e) {

System.out.println("Error: " + e);

}

}

}

mbarsic at 2007-6-29 1:27:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...