为什么我的jsp 老是和数据库连接不上

来源:百度知道 编辑:UC知道 时间:2024/06/03 17:02:00
还是连接数据库的事
我的conn.java
大侠们帮我看看有什么问题没好不
package com.bwm.db;
import java.sql.*;
public class Conn {
private static Connection con;
private Statement stmt;
private ResultSet rs;
private static final String drivername =
"com.microsoft.jdbc.sqlserver.SQLServerDriver";
private static final String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=plane;user=sa;password=sqlserver;";
public static synchronized Connection getCon() throws Exception {
try { Class.forName(drivername);
con = DriverManager.getConnection(url);
return con;
} catch (SQLException e) {
System.err.println(e.getMessage());
throw e;
}
}
public Statement getStmtread() {
try {
con = getCon();
stmt = con.createStatement(ResultSet.T

我测试过了,我这里没有sql2000,我用mysql测试,你的程序没什么问题,你检查其他的问题,如没有权限,有没有配置好jdbc驱动

改:private static final String url = "jdbc:sqlserver://localhost:1433;DatabaseName=plane;user=sa;password=sqlserver;";