Package test. Oracle;
Import java. SQL. *; // Add ojdbc6_g.jar to the project
Public class OJ {
Public static void main (String args []) {
String url = "jdbc: oracle: thin :@ localhost: 1521: orcl11 ";
Try {
Class. forName ("oracle. jdbc. driver. OracleDriver"); // after the table is created, commit can be called on other terminals.
Connection conn = DriverManager. getConnection (url, "system", "bbroot ");
Statement stmt = conn. createStatement (); // The insert Statement during table creation is remembered as ''instead ""
String strSql = "SELECT * FROM Test_JC"; // remove the SQL statements.
ResultSet rs1_stmt.exe cuteQuery (strSql );
While (rs. next ()){
System. out. println ("TestID:" + rs. getString (1 ));
System. out. println ("Describe:" + rs. getString (2 ));
}
}
Catch (Exception e ){
E. printStackTrace ();
}
System. exit (0 );
}
}
Output:
TestID: 001
Describe: ILOVEYOU
TestID: 002
Describe: JAVA
TestID: 003
Describe: Oracle