连接ACCESS数据库
//access driver
private StringBuffer accessURL=new StringBuffer("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=");
private String accessFilePath="";
private String accessFileName="";
//Method:connect to access file
public Connection getConnectionToAccess(String fileURL) throws SQLException,ClassNotFoundException
{
accessURL.append(fileURL);
Class.forName(driver);
conn=DriverManager.getConnection(accessURL.toString());
return conn;
}<jsp:useBean id="DBConnection" scope="page" class="com.huading.DBConnection"/>
Connection conn=DBConnection.getConnectionToAccess(application.getRealPath("/news/date/news.mdb"));
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 写了这段代码后还需要建立dsn源吗??
//access driver
private StringBuffer accessURL=new StringBuffer("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=");
private String accessFilePath="";
private String accessFileName="";
//Method:connect to access file
public Connection getConnectionToAccess(String fileURL) throws SQLException,ClassNotFoundException
{
accessURL.append(fileURL);
Class.forName(driver);
conn=DriverManager.getConnection(accessURL.toString());
return conn;
}<jsp:useBean id="DBConnection" scope="page" class="com.huading.DBConnection"/>
Connection conn=DBConnection.getConnectionToAccess(application.getRealPath("/news/date/news.mdb"));
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 写了这段代码后还需要建立dsn源吗??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货