以下代码提示错误:java.sql.SQLException: No suitable driver
publicclassDBConnection{//使用第三方JDBC驱动类privateStringDBDRIVER="com.microsoft.sqlserver....
public class DBConnection {
// 使用第三方JDBC驱动类
private String DBDRIVER ="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private String DBURL = "jdbc:jtds:sqlserver://127.0.0.1:1433;DataBaseName=EmployInfo";
private String DBUSER = "sa";
private String DBPASSWORD = "";
private Connection conn = null;
public DBConnection() {
try {
Class.forName(DBDRIVER);
this.conn = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
} catch (ClassNotFoundException e) {
System.out.println("*******error*******");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("*****error*******");
e.printStackTrace();
}
}
public Connection getConnection() {
return this.conn;
}
public void close() {
try {
this.conn.close();
} catch (SQLException e) {
System.out.println("***error............****");
e.printStackTrace();
}
}
} 展开
// 使用第三方JDBC驱动类
private String DBDRIVER ="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private String DBURL = "jdbc:jtds:sqlserver://127.0.0.1:1433;DataBaseName=EmployInfo";
private String DBUSER = "sa";
private String DBPASSWORD = "";
private Connection conn = null;
public DBConnection() {
try {
Class.forName(DBDRIVER);
this.conn = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
} catch (ClassNotFoundException e) {
System.out.println("*******error*******");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("*****error*******");
e.printStackTrace();
}
}
public Connection getConnection() {
return this.conn;
}
public void close() {
try {
this.conn.close();
} catch (SQLException e) {
System.out.println("***error............****");
e.printStackTrace();
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询