Problem with connecting oracle to Java ! [message #92357] |
Mon, 14 June 2004 20:08 |
Amith p Jayanthilal
Messages: 5 Registered: June 2004
|
Junior Member |
|
|
Hi,
i am trying to run this program(My code is at end of e-mail). I don't know whats wrong with it. It's just a simple program to connect from Java to Sql and then execute a simple query. I can see the first "hi" message in the program. But after that, once the connection is established, nothing is displayed on the screen. Not even second "HI" message. I am not even sure whether connection gets established or not.
Can anybody help me on this ?
I am damn sure about machine name, port#, SID, username and password used in the program. They are all right.
Waiting for ur reply,
Amith
import java.sql.*;
public class MyOwn{
public static void main(String args[[]]) throws SQLException{
System.out.println("hi");
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@akurach:2030:aaa",
"scott", "tiger");
System.out.println("HI");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("select DNAME from DEPT");
while(rset.next()){
System.out.println(rset.getString("DNAME"));
}
rset.close();
conn.close();
}
}
|
|
|
|