Java oracle connection [message #136764] |
Sat, 10 September 2005 00:02 |
sandeepkumar99
Messages: 3 Registered: September 2005 Location: Ernakulam
|
Junior Member |
|
|
I have wrriten a java prgrammme in JBuilder and I want to connect the front end of java with oracle as back end please reply as soon as possible.
|
|
|
|
|
Re: Java oracle connection [message #137752 is a reply to message #136966] |
Fri, 16 September 2005 09:51 |
bpeasey
Messages: 46 Registered: March 2005
|
Member |
|
|
I played with this last month and got a result set back.
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException {
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from emp");
while (rset.next())
System.out.println (rset.getString(2) + " " + rset.getString(3));
stmt.close();
}
}
Best Regards,
Brian Peasey
http://oracle-exam-study-groups.com
|
|
|