jsp连接SQL2000出错问题
来源:百度知道 编辑:UC知道 时间:2024/05/17 00:24:34
public static Connection getConnection()
{
Connection con=null;
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev";
String USER="sa";
String PWD="1";
try
{
Class.forName(CLASSFORNAME);
con = DriverManager.getConnection(SERVANDDB,USER,PWD);
}
catch(Exception e)
{
e.printStackTrace();
}
return con;
}
报错提示:(7,0) The value for the useBean class attribute com.jspdev.ch12.ViewCategory is invalid
我在jsp页面直接访问数据库是可以实现的,但写个bean然后在jsp里usebean一下就出错,报错提示:(7,0) The value for the useBean class attribute com.jspdev.ch12.ViewCategory is invalid
请问是哪出了问题
如果你确认是你这个连库文件错误的话,那我给我你我经常用的这个。
sqlserver2000 的:
public static Connection getConnection() {
Connection conn_ms = null;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
String user = "sa";
String password = "";
conn_ms = DriverManager.getConnection(url, user, password);
System.out.println("sql server连接成功");
} catch (Exception e) {
System.out.println("sql server连接失败");
e.printStackTrace();
}
return conn_ms;// conn_ora,conn_ms,conn_my
}
// 释放资源
public static void destory(Connection conn, Statement stmt, ResultSet rs) {
try {
if (stmt != null) {
stmt.close();
stmt = null;
}
if (conn != null) {
conn.close();