[Java]
/**
* Separate java programs connect to the oracle database
* Author: JavaAlpha
* Date: 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.exe cuteQuery (SQL );
While (rs. next () www.2cto.com
{
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 ();
}
}
}