首页 > 代码库 > java连接oracle
java连接oracle
//使用java操作oracle数据库的例子
//文件名:testora.java
//文件名: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");
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));
}
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();
}
e.printStackTrace();
}
}
}
java连接oracle
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。