用java直接连接Access数据源的方法
时间:2011-01-11
import java.sql.*;
public class Access{
public static void main(String args[]) throws Exception{
String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\projects\\demo.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(strurl) ;
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from mcp_swty_player");
while(rs.next())
System.out.println(rs.getString("player_mobile"));
rs.close();
stmt.close();
conn.close();
}
}
|