我刚学jsp连接数据库,老是抛出异常,哪位大师可以帮我指点一下。

来源:百度知道 编辑:UC知道 时间:2024/06/23 23:07:51
--------------------------------------------------------------------------------
抛出的异常内容如下,不知道数据库驱动的那地方设置有问题,请帮帮忙,谁能帮我解决我一定加分,紧急啊,谢了!
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /test_mysql.jsp at line 22

19: //联结字符串
20: String url="jdbc:mysql://localhost/shujuku?user=test&password=123456&useUnicode=true&characterEncoding=gb2312" ;
21: //String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
22: Class.forName("com.mysql.jdbc.Driver").newInstance();
23: Connection connection=DriverManager.getConnection(url);
24: Statement statement = connection.createStatement();
25: String sql="SELECT * FROM biao";

Class.forName("com.mysql.jdbc.Driver");
String strConn="jdbc:mysql://localhost/shujuku"+"?user=test&password=123456"+"&userUnicode=true&characterEncoding=gb2312";
Connection conn = DriverManager.getConnection(strConn);
Statement stmt=conn.createStatement();
String strSql = "SELECT * FROM biao";
ResultSet rs = stmt.executeQuery(strSql);
按照你的那个修改的,但是是我自己编写的数据库代码连接的,这个是成功的,你在获取数据库信息的时候连接符没有写,要注意。如果还不行的话,给我留言。