java链接Access数据库
import java.sql.*;
public class dbaccess{
public static void main(String args[]) throws Exception{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dburl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=Mobile.mdb";//此为NO-DSN方式
//String dburl ="jdbc:odbc:odbcName";//此为ODBC连接方式
Connection conn=DriverManager.getConnection(dburl);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select Top 20 * from MobileSection");
System.out.println("号段 地区 类型 省份 区号");
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5));
}
rs.close();
stmt.close();
conn.close();
}
}
补充:软件开发 , Java ,