环境:
MyEclipse6.0,Tomcat6.0,MySQL5.0 自己测试东西,客户端和服务端都在本机 数据库也在本机
我的web工程发布后,页面不能操作数据库,注意是连接正常,是不能做操作。我在程序里添加了一个main方法后在控制台运行 没有任何问题。
我的语句:
conn = DBUtil.getConnection();
String sql = "select * from student";
System.out.println(sql);
try {
PreparedStatement pstmt = conn.prepareCall(sql); ///////这里出错了
// set values
pstmt.setString(1, username);
pstmt.setString(2, password);
ResultSet rs = pstmt.executeQuery();
// 判断
if (rs.next()) {
login = true;
}
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
//System.out.println(e.getMessage());
} finally { // set nothing
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
web访问时报的错误是: (如果我是查询就 报: "table.student" does not exist )
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: FUNCTION * does not exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3118)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3047)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1166)
at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1269)
at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3668)
at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:638)
at com.mysql.jdbc.CallableStatement. <init>(CallableStatement.java:453)
at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4365)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4439)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4413)
at com.bobo.student.dao.StudentManager.checkUser(StudentManager.java:28)
at com.bobo.student.web.LoginCheck.doPost(LoginCheck.java:28)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Unknown Source)
我在main中测试 :DBUtil.getConnection().createStatement().execute("select * from student");
没有任何问题!!!!所以我觉得应该不时驱动问题!! 我坛子里也逛了 好像说是什么MYSQL权限问题!!!
--转自