code is on list:
String sql = "select stockid, sum(stocknumber) total from fundstockdetail where quarter=? group by stockid ";
st =con.prepareStatement(sql);
st.setInt(1,quarter);
ResultSet rs=st.executeQuery(sql);
but executeQuery report exception:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? group by stockid' at line 1
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:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
but "insert into fundstockdetail values(?,?,?,?,?,?,?,?)" is good running,
how can resolve this problem,and what's the reason?
I am use mysql-5.0.4,the jdbc driver is mysql-connector-java-5.0.4-bin.jar,
I try to change the jdbc driver version,but the problem still exists.
String sql = "select stockid, sum(stocknumber) total from fundstockdetail where quarter=? group by stockid ";
st =con.prepareStatement(sql);
st.setInt(1,quarter);
ResultSet rs=st.executeQuery(sql);
but executeQuery report exception:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? group by stockid' at line 1
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:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
but "insert into fundstockdetail values(?,?,?,?,?,?,?,?)" is good running,
how can resolve this problem,and what's the reason?
I am use mysql-5.0.4,the jdbc driver is mysql-connector-java-5.0.4-bin.jar,
I try to change the jdbc driver version,but the problem still exists.