每天进步一点点
每天进步一点点
package Test;
import java.sql.*;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class TestConnect {
    public TestConnect() {
    }
    static Connection con = null;
    public static void main(String args[]) {
      try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        //String url="jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=D://demo.mdb";
        String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D://demo.mdb";
        //String url = "jdbc:odbc:Access";
        con = DriverManager.getConnection(url,"","");
        Statement stmt = con.createStatement();
        String sql = "select * from base";
        ResultSet rs = stmt.executeQuery(sql);
        while (rs.next()) {
          System.out.println("name= " + rs.getString(1));
        }
        rs.close();
        stmt.close();
        con.close();
        //JakartaBasicDataSource.closeBasicDataSourceConnection();
      }
      catch (Exception e) {
        e.printStackTrace();
        System.out.println("now you have not ActiveConnection..........break!!");
      }
  }
}
posted on 2006-08-23 13:50 每天进步一点点 阅读(687) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: