import java.sql.*;
//用jdbc连接数据库
public class zz {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
//加载驱动
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORACLE","scott","m123");
Statement sm=con.createStatement();
ResultSet rs=sm.executeQuery("select * from emp");
System.out.println("用户名: "+"职位:"+"上司编号: "+"入职时间: ");
while(rs.next())
{
System.out.println(rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5));
}
rs.close();
sm.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
阅读(2196) | 评论(0) | 转发(0) |