请高手支招!
import java.sql.*;
public class testdb {
/**
* @param args
*/
public static void main(String[] args) throws
SQLException,
ClassNotFoundException{
// TODO Auto-generated method stub
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
System.out.println( "Driver loaded ");
Connection connection=DriverManager.getConnection( "jdbc:odbc:student ");
System.out.println( "Database connected ");
Statement statement=connection.createStatement();
ResultSet resultSet=statement.executeQuery( "select * from student ");
while(resultSet.next())
System.out.println(resultSet.getString(2)+ "\t "+resultSet.getString(3));
connection.close();
}
}
我运行这段代码的时候弹出一个错误对话框,上面提示说:
The archive:C:/Program Files/Java/jdk1.6.0/lib/jta-spec1_0_1.jar which is referenced by the classpath,does not exist.
------解决方案--------------------没有添加JDBC驱动中的jar