java连接到Access 2003,报错[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
做的是第五届 ITAT复赛题,代码如下
package text1;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class BFive6 {
public static void main(String[] args) throws Exception{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:student","","");
String sql = "select S_ID,S_Name,S_Email,S_Score from T_Student";
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getInt(4));
}
rs.close();
conn.close();
pstmt.close();
}
}
请各位高手指教!
[解决办法]
你在操作系统的ODBC数据源中,确定配置了student这个数据源么?