String uname="hr"; String passwd="hr1234"; Class.forName("oracle.jdbc.driver.OracleDriver");//加载驱动 Connection conn=null; String url="jdbc:oracle:thin:@192.168.57.128:1521:blue"; Statement stmt=conn.createStatement(); //创建语句 ResultSet rs=stmt.executeQuery("select * from Person");//和数据库建立连接 int i=0; while(rs.next ()) { i=i+1; } JOptionPane.showMessageDialog(f,"共有"+i+"名员工");//显示信息对话框 stmt.close (); conn.close (); //关闭到数据库的连接 } catch(Exception ex) { ex.printStackTrace(); }
添加回答
举报
0/150
提交
取消