PreparedStatement Error

I'm getting this error when i try submitting values from my Jsp page into a database:
Method preparedStatement(java.lang.String)not found in interface java.sql.Connection.
The arrow that appears usually beneath the code in the error 500 message suggests that the problem is occuring in the insert statement, and im thinking it does'nt like the question mark in place of the value.
Is this because im importing the wrong class? my current class string is:
@page contentType="text/html; charset=iso-8859-1" language="java" import="java.lang.string.*" import="java.sql.*"
This is what the line within the program looks like:-
quote = Connquote.preparedStatement("INSERT INTO table1(A, B, C, D, E, F, G, H, I, J, K, L, M, N) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");

But this gives me an error:
java.sql.SQLException:Parameter index out of range (1
number of parameters, w
If it says that it means you don't have any bind variables in your SQL.
Whah happens obj is null?Nothing to do with it. And you are writing code that is probably pointless as well. setObject() handles nulls.

Similar Messages

  • Java PreparedStatement error

    I have this statement:
    pstmt.setDouble(2, (double) 9000000000);
    where pstmt is PreparedStatement
    when I compile I got this error:
    SaveFocus2aCommand.java:666: integer number too large: 9000000000
    pstmt.setDouble(2, (double) 9000000000);
    ^
    1 error
    Does any one know what happens and how to solve this problem ? Thanks

    timhuy wrote:
    First, it is not generally considered a good idea to handle money as a double.I can make change to long easily
    Second, this is the case where you do cast it.Cast does not help either
    Third - read the exception. The database, not java, is telling you that you can't do that. Probably because the field is too small.
    This is close. I purposely embeded 9 billions as long (with the L), and the compile was OK. But the run time generated error again.
    I manually inserted 9 billiions into the table and it is OK. .
    So I guess, the problem is my client JDBC always look for integer although I the parameter is long or double.Well that statement is phrased badly or just wrong.
    You are calling setDouble() so it is using a double. There is no other possibility.
    My field is numeric(12) or double precisionThat specific field doesn't really look like a double to me. It looks like a integer with 12 digits.
    Certainly won't work for any money field either since there is no fractional part. And I could certainly see a JDBC driver interpreting that as an integer, and in that case it would refuse to convert a double to it. The double that you are passing in.
    Now if it was numeric(12,2) or numeric(14,2) then that would be more interesting.
    The fact that you used a GUI database tool to do something doesn't mean much because the tool is not the database itself.

  • MySQL PreparedStatement Error

    Hi all. Thanks for previous assistance. I am trying to select from MySQL using a PreparedStatement, however I keep getting the error below. I have included the code from JSP and my Java. When I run the Select statement from a command window it works properly and retrieves the proper information (when I replace the ? with the value from add_confirm.jsp prefix_var). I really appreciate any help.
    Gary
    *** utility.java ***
    public ResultSet getPrefix(int util_prefix) throws SQLException, Exception {
    ResultSet rs = null;
    try {
    PreparedStatement getPre;
    getPre = con.prepareStatement (
    "select a.util_id, a.util_abbr, a.util_name, b.util_db_id from pre_util a, power_source b where a.util_id = b.util_db_id AND b.util_db_id = ? ;");
    getPre.setInt(1, util_prefix);
    getPre.execute();
    } catch (SQLException e) {
    error = "SQLException: get failed" + e.getMessage();
    throw new SQLException(error);
    } catch (Exception e) {
    error = "Exception: An exception occurred while getting utility";
    throw new Exception(error);
    return rs;
    *** add_confirm.jsp ***
    <jsp:useBean id="utility" class="com.yb.util.user.utility" />
    int prefix_var = Integer.parseInt(request.getParameter("prefix"));
    out.println(prefix_var); // the value is being passed correctly
    utility.getPrefix((int) prefix_var);
    ResultSet rs = utility.getPrefix();
    while (rs.next()) {
    String prefix_st = "";
    prefix_st = rs.getString("a.util_abbr");
    *** My Error ***
    C:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\jsp\add_005fconfirm_jsp.java:92: getPrefix(int) in com.yb.util.user.utilitycannot be applied to ()
    ResultSet rs = utility.getPrefix();
    _______________^

    utility.getPrefix((int) prefix_var);
    ResultSet rs = utility.getPrefix();
    You're calling your method twice, the second time without a parameter.
    Try
    ResultSet rs = utility.getPrefix(prefix_var); (no cast should be necessary)

  • PreparedStatement error using VPD

    Hi all,
    Our team is developing an application using an Oracle DB 9.2.0.4 and BC4J 10g (9.0.5.16.0) as persistence layer.
    We also are using the VPD (virtual private database) to have security in the database at row level.
    The problem we are facing is that every some time (days) we get a jdbc error when a query (see below) that uses VPD policies is executed. Once the error occurs I execute it from sqlplus without getting any error .. it only occurs from our java application.
    To temporary solve this problem, we delete and recreate the VPD policies, then the application continue working fine for some time ...
    I'll appreciate any comment / suggestions
    Thank in advance.
    Eduardo.
    ERROR LOG:
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT CalLocation.ID,
    CalLocation.CODE, eo
    CalLocation.NAME,
    CalLocation.ZIP,
    CalLocation.PHONE,
    CalLocation.FAX,
    CalLocation.ADDRESS1,
    CalLocation.ADDRESS2,
    CalLocation.URL,
    CalLocation.OWNER,
    CalLocation.CTY_ID,
    CalLocation.DESCRIPTION,
    ORefCity.CODE CTY_CODE,
    ORefCountry.ID CTR_ID,
    ORefCountry.CODE CTR_CODE,
    ORefRegion.ID REG_ID,
    ORefRegion.CODE REG_CODE
    FROM CAL_LOCATIONS CalLocation,
    OREF_CITIES ORefCity,
    OREF_COUNTRIES ORefCountry,
    OREF_REGIONS ORefRegion
    WHERE ORefCity.ID = CalLocation.CTY_ID
    and ORefCountry.ID = ORefCity.CTR_ID
    and ORefRegion.ID = ORefCountry.REG_ID) QRSLT WHERE ( ( (CTY_ID = 867) ) )
    ## Detail 0 ##
    java.sql.SQLException: Io exception: Broken pipe
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
         at oracle.jdbc.driver.OracleStatement.open(OracleStatement.java:717)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2605)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:387)

    It seems to be related to the bug 3662364 .
    Regards,
    Eduardo.

  • Batch Updates in 6.0sp2 w/ JDriver

    Ok, I know this subject has been posted multiple times in this group but I still
    haven't been able to find a definitive answer. Does the OCI JDriver shipped with
    WLS6.0sp2 for HPUX support batch updates (specifically the 817_8 so's)? I'm getting
    the "This JDBC 2.0 method is not implemented for PreparedStatements" error so
    I am assuming not. I've seen posts claiming this was implemented in sp1 but it's
    not working for our sp2 implementation. Any feedback would be appreciated.
    -Erik

    Erik,
    Based on the error message that you copied in the message you can indeed
    conclude that the required functionality is not available in the OCI
    jDriver.
    Did you already have a look at the SequeLink driver?
    This JDBC 2.0 compliant driver does support batch updates.
    A free eval is available on www.merant.com/datadirect.
    Cheers,
    Dimitri
    "Erik" <[email protected]> wrote in message
    news:3b57c513$[email protected]..
    >
    Ok, I know this subject has been posted multiple times in this group but Istill
    haven't been able to find a definitive answer. Does the OCI JDrivershipped with
    WLS6.0sp2 for HPUX support batch updates (specifically the 817_8 so's)?I'm getting
    the "This JDBC 2.0 method is not implemented for PreparedStatements" errorso
    I am assuming not. I've seen posts claiming this was implemented in sp1but it's
    not working for our sp2 implementation. Any feedback would be appreciated.
    -Erik

  • PreparedStatment creating Syntax Error.

    The poblem is in the first prepared statment if I enter the value straight into the statement string everying works fine. However, when I use a ? for placeholder and then supply the same sting value i would have entered in the statement string I get a sytax error.
    import java.sql.*; import javax.swing.*; import java.awt.BorderLayout; import java.awt.event.*; public class Exercise34_5 extends JFrame { private JTextField jtfInput = new JTextField(10); private JButton jbShowTable = new JButton("Show Table"); private JTextArea jta = new JTextArea(); private PreparedStatement pstmt1; private PreparedStatement pstmt2; private PreparedStatement pstmt3; public Exercise34_5() { JPanel northPanel = new JPanel(); northPanel.add(new JLabel("Table Name")); northPanel.add(jtfInput); northPanel.add(jbShowTable); add(northPanel, BorderLayout.NORTH); add(new JScrollPane(jta)); try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test" , "root", "root"); pstmt1 = connection.prepareStatement("describe ?"); pstmt2 = connection.prepareStatement("select count(*) from enrollment"); pstmt3 = connection.prepareStatement("select * from enrollment"); }catch(Exception ex) { ex.printStackTrace(); } jbShowTable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String table = jtfInput.getText(); try{ pstmt1.setString(1, "enrollment"); /*pstmt2.setString(1, "enrollment"); pstmt3.setString(1, "enrollment");*/ ResultSet rset1 = pstmt1.executeQuery(); ResultSet rset3 = pstmt3.executeQuery(); int count = 0; while(rset1.next()) { jta.append(rset1.getString(1) + "\t"); count++; } jta.append("\n"); System.out.println(count); while(rset3.next()) { for(int i = 1; i <= count; i++) { jta.append(rset3.getString(i) + "\t"); } jta.append("\n"); } }catch(Exception ex) { ex.printStackTrace(); } } }); } public static void main(String[] args) { Exercise34_5 frame = new Exercise34_5(); frame.setSize(400, 200); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); } }
    java.sql.SQLException: Syntax error or access violation message from server: "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 ''enrollment'' at line 1"
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2251)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
    at Exercise34_5$1.actionPerformed(Exercise34_5.java:47)

    Alyosha wrote:
    I don't understand.You can't just put a ? parameter any old place in a prepared statement. It's just just a simple string substitution. For instance, you cannot use a ? parameter for a table name or a column name.
    // wrong
    ps = conn.prepareStatement("select * from ? where ? = ?");
    ps.setString(1, tableName);
    ps.setString(2, columnName);
    ps.setString(3, columnValue);
    // right
    ps = conn.prepareStatement("select * from " + tableName = " where " + columnName + " = ?");
    ps.setString(1, columnValue);

  • A question about PreparedStatement and ORA-03115 error

    Dear all,
    I have an issue with JDBC and I would appreciate if you could kindly give me a hand.
    I'm using:
    - Oracle Database 11g Enterprise (Release 11.1.0.6.0)
    - JDBC thin driver version: ( 11.1.0.7.0-Production)
    - JDK 1.6
    - Operating system: Linux (Ubuntu 8.10)
    Here is my code
    import java.sql.*;
    public class Main
        public static void main(String[] args)
            String dbURL = "jdbc:oracle:thin:@localhost:1521:mydatabase";
            String username = "scott";
            String user_password = "tiger";
            try
                Connection connection = DriverManager.getConnection(dbURL, username, user_password);
                String query_text = "SELECT * FROM mytable";
                Statement statement = connection.createStatement();
                ResultSet query_result = statement.executeQuery(query_text);
                connection.close();
            catch (SQLException e)
                for (Throwable t: e)
                    t.printStackTrace();
    }This works pretty well without any problem. But when I want to use PreparedStatement instead of Statement I receive the ORA-03115 error message, that is, when I replace the Statement with PreparedStatement in the following way:
    String query_text =
            "SELECT first_name, ?, id, ?, job_title, salary  FROM mytable "+
            "WHERE id IN ('id14', ?, 'id17', 'id18')";
    PreparedStatement prepared_statement =  connection.preparedStatement(query_text);
    prepared_statement.setString(1, "last_name");
    prepared_statement.setString(2, "birthday");
    prepared_statement.setString(3, "id02");
    ResultSet query_result = prepared_statement.executeQuery(query_text);I get the following:
    java.sql.SQLException: ORA-03115: unsupported network datatype or representation
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
         at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1377)
         at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:387)
         at mysqlpackage.Main.main(Main.java:33)Therefore, right after
    ResultSet query_result = prepared_statement.executeQuery(query_text);the exception is thrown,
    why it works with Statement but not with PreparedStatement? I tested with several other queries, insert a new row, delete a row, everytime it works well, but when I want to use PreparedStatement instead of Statement, again I have this error message.
    Any idea?
    Thanks in advance,

    OK, I found myself the answer.
    First error, I had use ? also for column names, which is not accepted as the SQL query has to be precompiled.
    Second error: Instead of writing
    ResultSet query_result =  prepared_statement.executeQuery(query_text);I had to write:
    ResultSet query_result =  prepared_statement.executeQuery();I tested with the following
    String query_text =
                  "SELECT first_name, last_name, id, birthday, job_title, salary "+
                  "FROM myenterprise "+
                  "WHERE id IN (?, ?, ?, ?) ";
                PreparedStatement prepared_statement =
                        connection.prepareStatement(query_text);
                prepared_statement.setString(1, "id02");
                prepared_statement.setString(2, "id04");
                prepared_statement.setString(3, "id08");
                prepared_statement.setString(4, "id09");
                ResultSet query_result =  prepared_statement.executeQuery();And it works pretty well now! :)

  • Error IllegalArgumentException in java.sql.Date used PreparedStatement

    I'm found bug (probably). I have a table with column DATA type. Now I connect do database use JDBC in Java, and create PreparedStatement:
    PreparedStatement stmt = conn.prepareStatement("insert into \"Appuser\" (\"IDUser\", \"createAccountDate\") values (?,?)");
    Column createAccountDate is a DATA type. And now I invoke:
    stmt.setInt(1, 1);
    stmt.setInt(2, new java.sql.Date(-2508265596206959779));
    stmt.execute();
    and last line return exception:
    java.lang.IllegalArgumentException
    at sun.util.calendar.ZoneInfo.getOffset(ZoneInfo.java:368)
    at oracle.jdbc.driver.DateCommonBinder.zoneOffset(OraclePreparedStatement.java:15423)
    at oracle.jdbc.driver.DateCommonBinder.setOracleCYMD(OraclePreparedStatement.java:15561)
    at oracle.jdbc.driver.DateBinder.bind(OraclePreparedStatement.java:15641)
    at oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(OraclePreparedStatement.java:2866)
    at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2151)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
    at // line stmt.execute();
    Another values of Data are OK. Probably value -2508265596206959779 cause that error.
    It's a bug? Better will be SQLException if it is a bug.
    My configuration:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Windows XP SP3, Java 1.6.0_20,
    ojdbc14.jar, Oracle JDBC Driver version - "10.2.0.1.0XE

    Probably value -2508265596206959779 cause that errorMaybe, whatever that .date( -ReallyLotsOfmSec ) date values is, pretty sure its outside the valid values for a date column, 4712BC to 9999AD is the min/max.
    Perhaps the java code can handle it, an oracle date type can not.

  • Using PreparedStatement and the Oracle Error ORA-1000

    Hi,
    I have a question about PreparedStatement objects that is not so simple to explain for me. What I would like to know is: if I use a PreparedStatement following traditional and generic steps:
    1- PreparedStatement pStmt = Connection.prepareStatement(sQuery);
    2- pStmt.setXXX(i,j);
    n - pStmt.setXXX(i,j);
    n+1 - ResultSet rs = pStmt.executeQuery();
    n+2 - while(rs.next()){ ... retrive ResultSet data  ... }
    n+3 - rs.close()
    n+4 - back to point number 2
    and at the end (as you can see in the point numbered n+4), instead of closing the PreparedStatement pStmt using the close() method, I reuse the PreparedStatement pStmt comeing back to the point numebr 2 and setting again all its parameters with new values ... then ... what heppens in the Oracle database ? Has been the cursor (so the mamory area), associated to my PreparedStatement object pStmt, duplicated or is it the same ?
    I know that Java allows you to do this kind of operations with PreparedStatement, and I know that in tha Java Documentation is explained to follow this strategy to optimize the execution time because in this way the same PreparedStatement is precompiled and prepared only once. But if I do a for loop following the steps explained before, after many iterations I have the error "ORA-1000: maximum open cursors exceeded". This error is the reason of my question. Does this error means that it's mandatory to close a PreparedStatement always, otherwise if you reuse it without closing it then the corresponding database cursor will be duplicated ? If it is so, then I think this is a contradiction with official java documentation ...
    I'm using Oracle8i (version 8.1.7) and Oracle JDBC Thin Driver (Windows NT) for use with JDK 1.2.x. Moreover, in my database istance the parameter "maximum open cursor" is equal to 800 ...
    Thank you very much for suggestions :-)

    There is no need to close a prepared statement or its resultset for every iteration.
    After the first iteration in a loop, all subsequent executions of it will close the previous resultset. By adding close() method, you are making one extra costly call to the DB for no reason.
    Following is the sample code.I know what you are saying. In fact at the beginning I wrote my code in the same way of your sample (see the code of my first post at the begin of this page).
    But doing so, after thousand iterations of the loop, I had "Oracle Error ORA-1000 : maximun open cursor exeeded" even if in my database istance the parameter "maximum open cursor" is equal to 8000.
    At this moment in my code, for each iteration, I close the PreparedStatement and in this way I don't have anymore the error :-((
    So it seems that only in theory we can reuse a preparedStatement without closing it. In fact if we see the oracle system table "$open_cursor" (as Konrad Pietzka suggest me) we can find that, for each interation,
    at our line code "rs = pstmt.executeQuery();" correspond a new cursor in the database: this means that for each method "pstmt.executeQuery()" the database open a new cursor and do not use the previous one as it should.
    I posted a question two months ago to search if someone had the same problem (it seems that Konrad Pietzka had the same situation) and was able to explain me what is the cause.
    The only reason I found by myself for this problem, is that probably the Oracle JDBC Thin Driver for Windows NT/2000 has some bugs... but I'm not sure ...
    Thank you very much for you time !!
    bye :-))
    Fidalma

  • JDBC error in PreparedStatement using TimesTen 6.0.3

    TimesTen supports this kind of sql statement
    select rows 3 to 5 * from products
    (it returns 2 rows started from row #3)
    I want to implement this in java thru JDBC
    PreparedStatement pstmt = con.prepareStatement(select rows ? to ? * from products);
    pstmt.setInt(1,3);
    pstmt.setInt(2,2);
    However, I got a JDBC error in the PreparedStatement line
    java.sql.SQLException: [TimesTen][TimesTen 6.0.3 ODBC Driver][TimesTen]TT1001: Syntax error in SQL statement before or at: "?", character position: 13 -- file "ptSqlY.y", lineno 1955, procedure "sbPtParseSql()"
    Anyone encounter this kind of error before? How to solve it?
    Thanks!
    Wellwin
    P.S. I am running this in Linux platform with JDBC driver come with TimesTen for java 1.4

    Hi Wellwin,
    Using SELECT ROWS m to n, you cannot parameterise m or n in order to provide them at execution time. They have to be explicitly stated as literals in the statement…
    If you need to use this with several different values for ‘m’ and ‘n’, there are a couple of options:
    1) Prepare (and subsequently execute) a different prepared statement for each combination of ‘m’ and ‘n’ that you need. This may be fine if there are only a small number of combinations but not a good choice if there are many combinations.
    2) Just use a regular SELECT (without the ROWS m TO n clause) and ‘skip’ the rows in the application code.
    Simon

  • Error in preparedstatement

    Hi
    Is this preparedstatement valid
    INSERT INTO TABLE2 (COL1,COL2,COL3,COL4)
    SELECT C1,C2,?,? FROM TABLE1 WHERE condn
    When I do con.prepareStatement() on this sql it is giving me error saying
    "Use of parameter marker not valid"
    Is this wrong??

    Is this preparedstatement valid
    INSERT INTO TABLE2 (COL1,COL2,COL3,COL4)
    SELECT C1,C2,?,? FROM TABLE1 WHERE condnOn oracle, that PreparedStatement will compile, but setting the parameters to the column names does not produce the expected result. The Strings are treated as constants, not as column names.
    If you set the parameters like this.
    pstmt.setString(1,"C3");
    pstmt.setString(2,"C4");
    You get the effective SQL being
    INSERT INTO TABLE2 (COL1,COL2,COL3,COL4)
    SELECT C1,C2,'C3','C4' FROM TABLE1 WHERE condn
    Could be different on other DBs.
    -Scott
    http://www.swiftradius.com

  • Error with passing a preparedstatement to another function.

    Hello,
    I'm quite new to the subject, but I've managed to stumble across a problem which I haven't been able to figure out by myself.
    I have a super class with the following function:
    protected boolean handleUpdateQuery(PreparedStatement preparedstatement, Connection connection) {
            succes = false;
            try {
                preparedstatement.executeUpdate();
                succes = true;
            } catch(Exception e) {
                e.printStackTrace();
            return succes;
        }And a child-class with the following function:
    public boolean updateArtikelSoort(int soortid, String naam, int btw, String verhuur) {
            succes = false;
            queryString = "UPDATE artikelsoort SET naam = ?, btw = ?, verhuur = ? WHERE soortid = ?";
            try {
                connection = super.openConnection();
                preparedstatement = connection.prepareStatement(queryString);
                preparedstatement.setString(1, naam);
                preparedstatement.setInt(2, btw);
                preparedstatement.setString(3, verhuur);
                preparedstatement.setInt(4, soortid);
                if(super.handleUpdateQuery(preparedstatement, connection)) {
                    succes = true;
            } catch(Exception e) {
                e.printStackTrace();
            super.closeConnection(connection);
            return succes;
        }This gets called by:
    if(sub.equals("wijzigdoorvoer")) {
                    artikelsoortdao.updateArtikelSoort(Integer.parseInt(request.getParameter("soortid")), request.getParameter("naam"), Integer.parseInt(request.getParameter("btw")), request.getParameter("naam"));
                }Somewhere along the line things get a bit messy, I've been trying to play around with preparedstatement, but all my tries worked, so I think the problem is here:
    if(super.handleUpdateQuery(preparedstatement, connection)) {
                    succes = true;
                }Maybe the problem is very obvious, but like I've said I'm just making my first steps into Java ;)
    I hope I can get some help here.
    Kind regards.

    Sometimes...
    I feel ashamed to type, after reading my forumpost for typo's
    I saw something was wrong with the parameters in my call to updateArtikelSoort();

  • PreparedStatement strange error

    Hi. When I use Prepared statement like this:
    first, in the constructor I create it:
    PS = con.prepareStatement("SELECT text FROM arts WHERE title = ? LIMIT 1;");and use it:
    PS.setString(1, title); // title is a String - I'm sure
    ResultSet rs = PS.executeQuery();I get and an exeption with the message "Operation on empty result set" when I use it.
    However, when I chenge the code a bit (not use PreparedStatement):
    ResultSet rs = con.createStatement().executeQuery("SELECT text FROM jokes WHERE title = \"" + title + "\" LIMIT 1;");everything is fine. Why's that? I have other prepared statements, which do work, so this implies I'm doing sth wrong with the "?" and setString() method. Any suggestions?

    The code is:
    1. in the constructor of my class I create the PreparedStatements
    2. each method calls one statement - and the two without the "?" work fine
    3. the code I posted first time wass all good, except the second code snippet took values from a different table - and this was a mistake while writing the post. In my program the tables are the same, the only difference is that the Prepared statement doesn't work. Here is the code again:
    public class ArtsContainer {
        private final String URL = "jdbc:mysql://localhost/arts";
        private final String LOGIN = "arts";
        private final String PASS = "arts";
        private final PreparedStatement COUNT;
        private final PreparedStatement TITLES;
        private final PreparedStatement ART;
        private final Connection con;
        public ArtsContainer() SQLException {
            try {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection(URL, LOGIN, PASS);
                COUNT = con.prepareStatement("SELECT COUNT(*) FROM art;");
                TITLES = con.prepareStatement("SELECT title FROM art;");
                ART = con.prepareStatement("SELECT text FROM art WHERE title = ? LIMIT 1;");
            }  catch (ClassNotFoundException ex) {
                throw new SQLException("Couldn't load MySQL Driver. Is it in the CLASSPATH?");
        public int getArtsCount() SQLException {
            ResultSet rs = COUNT.executeQuery();
            rs.first();
            return rs.getInt(1);
        public Art getArt(String title) SQLException {
            ART.setString(1, title);
            ResultSet rs = ART.executeQuery();
            //ResultSet rs = con.createStatement().executeQuery("SELECT text FROM art WHERE title = \"" + title + "\" LIMIT 1;");
            rs.first();
            Art art = new Art(title, rs.getString(1));  // here is the exception
            return art;
        public String[] getTitles() SQLException {
            ResultSet rs = TITLES.executeQuery();
            String[] titles = new String[getArtsCount()];
            int count = 0;
            while (rs.next()) {
                titles[count] = rs.getString(1);
                ++count;
            return titles;
    }The queston regards the getArt() method. When I use it like this I get the exception in the line marked above. When I use the commented line, it's all ok.

  • PreparedStatement inserting error

    hi, I am developing a web(Servlet) application with
    jdk 1.2.1 on Unix with Oracle 8.0.5 residing
    on NT 4.0. I also used thin 816class driver.
    when I use PreparedStatement like :
    pstmt= insert into table_name (a,b) values (?,?)
    pstmt.setString(1, one);
    pstmt.setString(2, two);
    I get on the Oracle DB a= two, b= one.
    the orders get messed up, is there are problems with thin driver or PreparedStatement itself.
    null

    It's possible that this is a driver bug.
    I would suggest you demo the third-party JDBC 2.0 drivers provided by Openlink Software (http://www.openlinksw.com). This will not be a problem for you with these drivers, as I have tested this syntax myself.
    More information on the JDBC drivers themselves can be found at: http://www.openlinksw.com/info/docs/rel3doc/jdbc/jdbcindx.htm
    Best regards,
    Stephen Schadt

  • Error  while assigning resultset value to Querytable variable in Coldfusion 10

    We are upgrading from coldfusion 8 to 10. Internally we were using java function to to get the data.
    In java function we have a resultset object, if we assign this resultset value to Querytable variable, we are getting below error. This code was working fine in coldfusion 8.
    Detail    This exception is usually caused by service startup failure. Check your server configuration.
    Message    The Runtime service is not available.
    StackTrace    coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.runtime.RequestMonitor.<clinit>(RequestMonitor.java:14) at coldfusion.sql.QueryTable.populate(QueryTable.java:358) at coldfusion.sql.QueryTable.populate(QueryTable.java:283) at coldfusion.sql.QueryTable.<init>(QueryTable.java:96) at com.myCompany.myClass.myFunct(myClass.java:627) at
    Here is the function which is causing error.
    static private QueryTable myFunct(String userId, SessionFactory sf) {
            PreparedStatement pStmt = null;
            ResultSet rs = null;
            QueryTable ret = null;
             try{
                Query q = sf.getCurrentSession().getNamedQuery("ListUsers");
                pStmt = sf.getCurrentSession().connection().prepareStatement(q.getQueryString());
                rs = pStmt.executeQuery();// works fine till here
                ret = new QueryTable(rs);  // error line         
                rs.close();
            }catch(Exception e){
                e.printStackTrace();
                throw new RuntimeException(e.getLocalizedMessage());
            return ret;
    Can you provide some help on this. Please let me know if you need any other details.

    We have found this error is logs
    coldfusion.runtime.Encryptor$InvalidParamsForEncryptionException: An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same..
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:303)
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:284)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5353)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5326)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5458)
        at com.vmware.vcp.service.impl.EncryptColdFusionImpl.decrypt(EncryptColdFusionImpl.java:65)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.initEmailService(ApplicationConfigSer vlet.java:119)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.init(ApplicationConfigServlet.java:51 )
        at javax.servlet.GenericServlet.init(GenericServlet.java:160)
        at coldfusion.bootstrap.ClassloaderHelper.initServletClass(ClassloaderHelper.java:121)
        at coldfusion.bootstrap.BootstrapServlet.init(BootstrapServlet.java:59)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5001)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5278)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

Maybe you are looking for

  • Skype getting off

    I have a sony bravia ex65 Led tv with skype ready tv. I bought cmu-br100 Camera and used skype. After 2 Months the skype after connet it is disconnecting saying camera is disconneted. Kindly help me in solving this problem. My email is *removed for p

  • Avi, mpeg and mov problems

    I`m having no luck playing streamed .avi, mpg and .mov ( all video) files. The avi and mpeg video files freeze up upon start up and only show the first second of the video for the first 5-10 minutes. After that they play fine although with no sound.

  • How to change layout of report  S_ALR_87012083?

    Hi everybody,     How to change layout of report  S_ALR_87012083 except change  output control at selection screen ?     For example,I need a list that there have vendor no. at every line of open item,and I don't need Total liabilities for every vend

  • Reg Disabling command field in Portal

    I have an requirement where in the command field should be disabled while calling a Tcode in Portal. I.e. After i call a Tcode in Portal, the command field box should not be there for the user to go for another transaction. How can i achieve this??

  • Save for Web darker interface

    I have for a long time been an advocate for the darker interface, using it mainly in After Effects. So it's great that the CS6 apps have taken this to other apps in the Suite. However Save for Web has been missed out it seems. Anyone else think this