Home > Back-end >  You greatly, I just learning to connect the database, I just want to check I select data, but every
You greatly, I just learning to connect the database, I just want to check I select data, but every

Time:12-26

Import the Java. SQL. Connection;
Import the Java. SQL. DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
Import Java, SQL Statement;

Public class Ocracle Conn {
Public static void main (String [] args) {
Try {
The Connection conn=DriverManager
GetConnection (" JDBC: oracle: thin @ localhost: 1521: XE ", "user", "pass");
Sout (" successful Database connect ");
Statements STMT=conn. CreateStament ();
The ResultSet rs=STMT. ExecuteQuery (select * form empt, dept ");
While (rs), next ()) {
Sout (rs. Get string (" name ") + rs. Get int (" ID ") + rs. Get string (" department ")); }

Conn close ();
} the catch (SQL Exception e) {
Sout (e);
Sout (" Database connect error "+ um participant etmessage ());
}}}}//sout=System. Out. Println
  • Related