mysql只能select,不能insert?

04-05-13 vesor
connector/j 3 mysql 4 tomcat 5

以root运行,all privallege,不是权限问题啊。

exception

javax.servlet.ServletException: Can not issue data manipulation statements with executeQuery()

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)

org.apache.jsp.bookshop.register_jsp._jspService(register_jsp.java:97)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

root cause

java.sql.SQLException: Can not issue data manipulation statements with executeQuery()

com.mysql.jdbc.Statement.executeQuery(Statement.java:1104)

org.apache.jsp.bookshop.register_jsp._jspService(register_jsp.java:73)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

wildfox
2004-05-14 11:58
/**

* Executes the given SQL statement, which returns a single

* <code>ResultSet</code> object.

*

* @param sql an SQL statement to be sent to the database, typically a

* static SQL <code>SELECT</code> statement

* @return a <code>ResultSet</code> object that contains the data produced

* by the given query; never <code>null</code>

* @exception SQLException if a database access error occurs or the given

* SQL statement produces anything other than a single

* <code>ResultSet</code> object

*/

ResultSet executeQuery(String sql) throws SQLException;

/**

* Executes the given SQL statement, which may be an <code>INSERT</code>,

* <code>UPDATE</code>, or <code>DELETE</code> statement or an

* SQL statement that returns nothing, such as an SQL DDL statement.

*

* @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or

* <code>DELETE</code> statement or an SQL statement that returns nothing

* @return either the row count for <code>INSERT</code>, <code>UPDATE</code>

* or <code>DELETE</code> statements, or <code>0</code> for SQL statements

* that return nothing

* @exception SQLException if a database access error occurs or the given

* SQL statement produces a <code>ResultSet</code> object

*/

int executeUpdate(String sql) throws SQLException;

猜你喜欢