先检查你的数据源里是不是存在你所要的数据库表,然后看看你的数据库驱动程序是否正确,你可以这样写:
public class DBConnection{
private static String jdbcDriver="sun,jdbc.odbc.JdbcOdbcDriver";
private static String dbName="数据库名";
private static String urlRoot="jdbc:odbc:";
public DBConnection(){
registerDriver();
}
public void registerDriver(){
String url=urlRoot+dbName;
try{
Class.forName(jdbcDriver);
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(SQL语句);
.
.
.
}
catch(ClassNotFoundException e){
System.err.println(e.getMessage());
}
catch(SQLException e){
System.err.println(e.getMessage());
}
public class DBConnection{
private static String jdbcDriver="sun,jdbc.odbc.JdbcOdbcDriver";
private static String dbName="数据库名";
private static String urlRoot="jdbc:odbc:";
public DBConnection(){
registerDriver();
}
public void registerDriver(){
String url=urlRoot+dbName;
try{
Class.forName(jdbcDriver);
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(SQL语句);
.
.
.
}
catch(ClassNotFoundException e){
System.err.println(e.getMessage());
}
catch(SQLException e){
System.err.println(e.getMessage());
}
你给的错误信息看不出什么最好是把代码贴出来。一般问题不大在检查一下你的连接参数
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 不能再打开其它
表了。