编程工具是myecplise8.6,我在myecplise里已经成功配置好了数据库,但是程序里面异常,请大家帮忙解决以下
[code="java"]import java.sql.*;
public class SqlTest {
private String driverClass = "net.sourceforge.jtds.jdbc.Driver";
private String url ="jdbc:jtds:sqlserver:/localhost:1433/demo";
private String user = "sa";
private String password = "";
private Connection connection;
public Connection openConnection() throws SQLException {
try {
Class.forName(driverClass).newInstance();
System.out.println("Successful");
connection = DriverManager.getConnection(url, user, password);
return connection;
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
public void closeConnection() {
try {
if (connection != null)
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws SQLException{
SqlTest st=new SqlTest();
Connection con=st.openConnection();
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select * from STCKSZ");
rs.next();
System.out.println(rs.getInt(1));
}
} [/code]
异常信息:
Exception in thread "main" java.sql.SQLException: net.sourceforge.jtds.jdbc.Driver
at test.SqlTest.openConnection(SqlTest.java:25)
at test.SqlTest.main(SqlTest.java:39)
麻烦大家拉