做的是第五届 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这个数据源么?
------其他解决方案--------------------------------------------------------
配置了
------其他解决方案--------------------------------------------------------
好了,原来没配置好呀,谢谢O(∩_∩)O谢谢