Package com. Oracle. ConnTest;
Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. ResultSet;
Import java. SQL. SQLException;
Import java. SQL. Statement;
/**
* Oracle connected to the bridge
* @ Author jll
*/
Public class ResConn {
Public static void main (String [] args) throws SQLException {
ResultSet rs = null;
Connection ct = null;
Try {
/**
* In the data source ODBC user DSN of the management tool on the control panel, add a connection Driver Name MyOracle
* Select the database created by some users in the current data.
*/
Class. forName ("Sun. jdbc. odbc. JdbcOdbcDriver");// Driver Configuration
Ct = DriverManager. getConnection ("Jdbc: odbc: MyOracle "," scott ",
"123");// Scott is the Login User Name. 123 is the password.
Statement st = ct. createStatement ();
Rs = st.exe cuteQuery ("Select * from emp");
While (rs. next ()){
/*
* The number of getString parentheses is determined based on the column fields in the oracle table, and starts from 1.
*/
System. out. println ("username:" + rs. getString (2 ));
System. out. println ("Employee Salary:" + rs. getString (6 ));
System. out. println ("");
}
} Catch (Exception e ){
E. printStackTrace ();
} Finally {
/**
* Close the data source
*/
Rs. close ();
Ct. close ();
}
}
}