While duelling with Java sql and preparedstatement I got this error.
This was due to using the query both in initiating prepared statement and while executing it.
The solution is to omit the query parameter from executeQuery
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe", "Birrah", "String sqlQuery = "SELECT x, y, z VIEWgup where dt > ?";
PreparedStatement ptmt = conn.prepareStatement(sqlQuery);
ptmt.setDate(1, new java.sql.Date(sonTarih.getMillis()));
ResultSet rset = ptmt.executeQuery (sqlQuery);
//this executequery statement above should be called woth no parameters.
This was due to using the query both in initiating prepared statement and while executing it.
The solution is to omit the query parameter from executeQuery
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe", "Birrah", "String sqlQuery = "SELECT x, y, z VIEWgup where dt > ?";
PreparedStatement ptmt = conn.prepareStatement(sqlQuery);
ptmt.setDate(1, new java.sql.Date(sonTarih.getMillis()));
ResultSet rset = ptmt.executeQuery (sqlQuery);
//this executequery statement above should be called woth no parameters.
Thank you. Your blog posting just helped solve my problem.
ReplyDelete