/**
* Separate Java program connects to the Oracle database
* Author:javaalpha
* date:2012-12-3 12:02:44
*/
Import java.sql. *;
public class Test {
public static void Main (string[] args) {
String driver = "Oracle.jdbc.driver.OracleDriver" ;
String url = "JDBC:ORACLE:THIN:@192.168.1.1:1521:ORCL";
String user = "root";
String password = "123456";
try {
Class.forName (driver);
Connection conn = drivermanager.getconnection (URL, user, password);
if (!conn.isclosed ())
System.out.println ("succeeded connecting to the database!");
Statement Statement = Conn.createstatement ();
String sql = "Select PASSWORD from USER WHERE id= ' test1 '";
ResultSet rs = statement.executequery (SQL);
while (Rs.next ())
{
System.out.println (rs.getstring ("PASSWORD"));
}
Rs.close ();
Conn.close ();
} catch (ClassNotFoundException e) {
System.out.println ("Sorry,can ' t find the driver!");
E.printstacktrace ();
} catch (SQLException e){
E.printstacktrace ();
} catch (Exception e) {
E.printstacktrace ();
}
}
}