各位兄弟姐妹,早上好,我是jsp菜鸟,昨天试了下用dreamweaver链接mysql数据库时,报错~~
我的新建的是jsp页面,在数据库面板中选择了MYSQL驱动程序,
驱动连接名称:jsp
驱动程序:org.gjt.mm.mysql.Driver
URL:jdbc:mysql://[hostname]/[database name]在单击测试的时候报错:
org/gjt/mm/mysql/Driver class not found请问这是为什么,谢谢各位!!
我的新建的是jsp页面,在数据库面板中选择了MYSQL驱动程序,
驱动连接名称:jsp
驱动程序:org.gjt.mm.mysql.Driver
URL:jdbc:mysql://[hostname]/[database name]在单击测试的时候报错:
org/gjt/mm/mysql/Driver class not found请问这是为什么,谢谢各位!!
这是你原封不动的URL嘛?
是的话把[hostname]/[database name] 换成真实的路径如果你写的就是真实路径的话,换个驱动试试
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs", "root" , "root");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public static Statement createStmt(Connection conn) {
Statement stmt = null;
try {
stmt = conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return stmt;
}
public static ResultSet executeQuery(Statement stmt, String sql) {
ResultSet rs = null;
try {
rs = stmt.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
/*public static ResultSet executeQuery(Connection conn, String sql) {
Statement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
中的hostname是啥?
database name是啥?多谢多谢!
database name 是你建立的数据库名称