www.pudn.com > TestToolsProject.rar > LoginAccessDatabase.java, change:2013-09-02,size:866b


package com.mervyn.testsource; 
 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
 
public class LoginAccessDatabase { 
 
	public ResultSet LoginAccessData() { 
		String DB_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver"; 
		//DSAccess为数据源名称; DBQ=数据库文件的绝对路径 
		String DB_URL = "jdbc:odbc:DSAccess;DBQ=e:\\ponbackup.mdb"; 
		ResultSet  rs=null; 
		try { 
			Class.forName(DB_DRIVER); 
			Connection conn = DriverManager.getConnection(DB_URL, "", ""); 
			PreparedStatement pstmt = conn.prepareStatement("select * from tb_product_result"); 
			rs = pstmt.executeQuery(); 
		} catch (ClassNotFoundException e) { 
			e.printStackTrace(); 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
		return rs; 
		 
	} 
}