首页 > 代码库 > JDBC的操作

JDBC的操作

 

 1 import java.sql.*; 2 public class TestJDBC { 3  4     public static void main(String[] args) throws Exception { 5         Class.forName("oracle.jdbc.OracleDriver"); 6         Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","scott","tigger"); 7         Statement stmt = conn.createStatement(); 8         ResultSet rs = stmt.executeQuery("select * from emp"); 9         while(rs.next()) {10             System.out.println(rs.getString("deptno"));11         }12         rs.close();13         stmt.close();14         conn.close();15     }16 17 }

 

JDBC的操作