码迷,mamicode.com
首页 > 数据库 > 详细

JDBC的操作

时间:2014-12-05 22:39:38      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

bubuko.com,布布扣

 

 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的操作

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/hixin/p/4147543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!