
| /*********************************************** /* /*DbTest.java /* /******************************************* */ import java.sql.*; public class DbTest { Connection con; Statement sta; ResultSet rs; String driver; String url; String user; String pwd; public DbTest() { driver = "sun.jdbc.odbc.JdbcOdbcDriver"; url = "jdbc:odbc:store_manager"; user = "share"; pwd = "share"; init(); } public void init() { try{ Class.forName(driver); System.out.println("driver is ok"); con = DriverManager.getConnection(url,user,pwd); System.out.println("conection is ok"); sta = con.createStatement(); rs = sta.executeQuery("select * from room"); while(rs.next()) System.out.println(rs.getInt("roomNum")); }catch(Exception e) { e.printStackTrace(); } } public static void main(String args [])//自己替换[] { new DbTest(); } } |
| driver is ok conection is ok 1001 1002 1003 1004 1005 1006 Press any key to continue... |
| 关于我们 | 联系我们 | 广告服务 | 工作机会 | 版权声明 | 欢迎投稿 | 网站地图 |
| Copyright © 2000-2008 , www.21tx.com , All Rights Reserved . |
| © 晨新科技 版权所有 Created by TXSite.net |