首页 > 数据库技术 > 详细

java连接oracle

时间:2014-12-17 14:15:40      阅读:230      评论:0      收藏:0      [点我收藏+]
//使用java操作oracle数据库的例子
//文件名:testora.java
import java.sql.*;
public class testora {
    public static void main(String args[]) {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
            Connection conn = DriverManager.getConnection("jdbc:odbc:myorc80","username","password");
            Statement sm=conn.createStatement();
            ResultSet rs=sm.executeQuery("select * from emp");
            
            System.out.println("编号"+"  "+"姓名"+"  "+"职位"+"  "+"领导编号"
                +"  "+"雇佣日期"+"  "+"工资"+"  "+"奖金"+"  "+"部门编号");
            while(rs.next()) {
                System.out.print(rs.getString(1)+"  ");
                System.out.print(rs.getString(2)+"  ");
                System.out.print(rs.getString(3)+"  ");
                System.out.print(rs.getString(4)+"  ");
                System.out.print(rs.getString(5)+"  ");
                System.out.print(rs.getString(6)+"  ");
                System.out.print(rs.getString(7)+"  ");
                System.out.println(rs.getString(8));
            }
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

java连接oracle

原文:http://www.cnblogs.com/gorechen/p/4169105.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!