CF 8 and  prepared statement RETURN_GENERATED_KEYS

It seems that for CF 8 is using RETURN_GENERATED_KEYS when
creating prepared statements. Is there any way to change this
behavior?

It seems that for CF 8 is using RETURN_GENERATED_KEYS when
creating prepared statements. Is there any way to change this
behavior?

Similar Messages

  • Statement and Prepared Statement

    if i write a same query with statement and preparedStatement
    like
    Select * from emp_detail where emp_id =20;
    stmt= con.createStatment();
    rs = stmt.executeQuery(query);
    and using preparedStatement
    Select * from emp_detail where emp_id =?;
    pstmt= con.prepareStatement();
    pstmt.setInt(1,20);
    rs = stmt.executeQuery(query);
    Using which statment(Statement or Prepared Statement) the data will retrive fast and why.... in these case ????

    Statement should be quicker than Prepared Statement, because
    Statment do only one thing: send that sql to server or run that sql directly.
    Prepared Statement should do two (or more than two)things:
    1. parse your sql first, prepare a store procedure, then call that store procedure.
    Or
    2. prase your sql first, then use your value to replace "?" for getting a new sql, then work like Statement.
    Prepared Statement is quiker when you use it repeatedly.

  • Weblogic and prepared statement

    We had an odd situation in production. We had a situation where we would always get a ORA-00904 Invalid Column name when running the following bit of code (via the prepared statement):
                   preparedStatement = con.prepareStatement("select * from KO_USER where GLOBAL_ID=?");
                   preparedStatement.setInt(1,thisGlobalId);
                   rs = preparedStatement.executeQuery();
    But when we simply converted it to a regular statement, as below, it ran fine.
                   preparedStatement = con.createStatement();
                   rs = preparedStatement.executeQuery("select * from KO_USER where GLOBAL_ID="+thisGlobalId);
    Can anyone explain this behavior? We use prepared statements throughout our codebase and never had a problem with it before.
    Thanks for any insight.
    Sara

    Poornima wrote:
    Is the prepared statement cache common to all the Connection objects in the Connection Pool or is there a separate cache for each statement in the Connection Pool?There is a separate statement cache for each connection in the pool.
    Joe

  • Help with streaming result sets and prepared statements

    hi all
    I create a callable statement that is capable of streaming.
    statement = myConn2.prepareCall("{call graphProc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}",java.sql.ResultSet.TYPE_FORWARD_ONLY,
    java.sql.ResultSet.CONCUR_READ_ONLY);
    statementOne.setFetchSize(Integer.MIN_VALUE);
    the class that contains the query is instantiated 6 times the first class streams the results beautifully and then when the second
    rs = DatabaseConnect.statementOne.executeQuery();
    is executed I get the following error
    java.sql.SQLException: Can not use streaming results with multiple result statements
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
    at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1370)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1688)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3031)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:943)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1049)
    at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:589)
    the 6 instances are not threaded and the result set is closed before the next query executes is there a solution to this problem it would be greatly appreciated
    thanks a lot
    Brian

    Database resources should have the narrowed scope
    possible. I don't think it's a good idea to use a
    ResultSet in a UI to generate a graph. Load the data
    into an object or data structure inside the method
    that's doing the query and close the ResultSet in a
    finally block. Use the data structure to generate
    the graph.
    It's an example of MVC and layering.
    Ok that is my bad for not elaborating on the finer points sorry, the results are not directly streamed into the graphs from the result set. and are processed in another object and then plotted from there.
    with regards to your statement in the beginning I would like to ask if you think it at least a viable option to create six connections. with that said would you be able to give estimated users using the six connections under full usage.
    just a few thoughts that I want to
    bounce off you if you don't mind. Closing the
    statement would defeat the object of of having a
    callable statement How so? I don't agree with that.
    %again I apologise I assumed that since callable statements inherit from prepared statements that they would have the pre compiled sql statement functionality of prepared statements,well If you consider in the example I'm about to give maybe you will see my point at least with regards to this.
    The statement that I create uses a connection and is created statically at the start of the program, every time I make a call the same statement and thus connection is used, creating a new connection each time takes up time and resources. and as you know every second counts
    thanks for your thoughts
    Brian.

  • Date objects and prepared statements

    Hi, I am trying to parse a String into a Date object with format "dd/MM/yyyy hh/mm/ss". Anyway, i have a method in a separate class which reads in a String and converts it to a formatted Date object.
    static public Date convertToDate(String t) throws ParseException {
    Date dd = new Date();
    ParsePosition p = new ParsePosition(0);
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    //y, M, etc are retrieved as substrings of String t. I know these methods are deprecated as well
    dd.setYear(y);
    dd.setMonth(M);
    dd.setDate(d);
    dd.setHours(h);
    dd.setMinutes(m);
    dd.setSeconds(s);
    String formattedDate = formatter.format(dd);
    Date theDate = formatter.parse(formattedDate);
    return theDate;
    Anyway, I am trying to use this in an SQL statement because I am using an Access DB which has a field of Date/Time value. Is this correct to use a Date object then? I have a prepared statement -
    PreparedStatement query = connection.prepareStatement(
    "SELECT FText FROM wnioutput WHERE Id = ? AND Section = ? AND Start = " +
    "? AND Field = ?");
    //start is the Date object returned from the previous method in a separate class
    query.setInt(1, id);
    query.setInt(2, section);
    query.setDate(3, formattedStart); - with this part, i get a setDate method not found, or something
    query.setString(4, ch);
    Can anybody tell me what the problem is? I know there are Date objects of java.util and java.sql. Should i be using an sql Date object? And if so, how, and where do I do this? Thank you!

    ok, i just tried
    query.setTimestamp(3, new java.sql.Timestamp(formattedStart.getTime()));
    where formattedStart is a java.util.Date object
    and I get the following error message -
    Error occured in getting endDateAndTime: java.sql.SQLException: Exception in databaseDisplay: the error message is:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    java.lang.NullPointerException
    where endDateAndTime is
    // takes in the startDateAndTime as a formatted String (before it is converted into a Date object)
    public String getEndTime(int s, int ID, String stDateAndTime) {
    String end = null;
    gui g = new gui();
    try {
    String sql = "SELECT End FROM wnioutput WHERE Id = " + ID +
    " AND Section = " + s +
    " AND Start = '" + stDateAndTime + "' AND Field = 'Wind50m'";
    ResultSet result = g.queryDatabase(sql);
    if (result.next())
    end = result.getString("End");
    } catch (SQLException sqlex) {
    System.out.println("Error occured in getting endDateAndTime: " + sqlex.toString());
    return end;
    Although this method worked fine before. So the error is in setting the date object in the prepared statement. Anymore suggestions??

  • Help with calling stored procedure and preparing statement

    hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();
                con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
                *cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
    ERROR:
    Incompatible Types
    Found : java.sql.Statement
    Required: java.sql.CallableStatement

    Nevermind guys..i got it..
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();           
                cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
                }     Edited by: daimous on Jan 31, 2008 6:04 PM

  • Connection/ResultSets/Prepared Statement opening and closing

    Hi all another question that was sparked by a thread that I recently read. I believe it was duffmo who got the code from jverd. The code I am referring to is to have an open and close connection specified in a Utility or Database class. I wanted to know if there was any issues with having methods that open and close connections/result sets/ preparedStatements. Currently I am putting the finally blocks inside each of my methods. There is obvious benefits to putting the methods in a class on their own (namely code re-use) but I wanted to know if there are any dangers. (This may seem like a dumb question, but I've found from experience it's the things that you don't know that will cost you loads of time).
    thanks again.

    Hi all another question that was sparked by athread
    that I recently read. I believe it was duffmo who
    got the code from jverd. Generally speaking it's fine.
    But as always you may have some long term design
    issues to think about. If you build a simple
    framework that consists of one class and that does
    all that your program does then great.
    Once you start add more complexity though you'll want
    to be careful that you aren't reinventing the Spring
    wheel or even ending up implementing your own
    connection pool. Both of which, judging from posts
    here seem to happen from time to time.
    So I guess all in all, yes it's much better than
    scattering the code all about but depending on what
    you are going to be doing with it you may want to
    look at the various ORM frameworks to see if they are
    really the direction you should be going in.Thanks for the information cotton. I just wanted to make certain that it was a sensible thing to do. When I had first asked about connections I was told they should be opened an closed in the same spot, unfortunately I took that explanation a little too much to heart, and started opening and closing every connection resultset and prepared statement in each of the DAO classes that I was using.
    Guess it's going to be a bit of work to refactor, but worth it for the cleaner code that will result.

  • Prepared Statement and Stored Procedure difference?

    For SQL in my web applications I use PreparedStatement object alot in my JDBC working with Oracle 9i.
    I also heard the term Stored Procedure. What is the difference between Stored Procedure and Prepared Statement?

    I am new to java programming, can anybody explain
    what exactly precompiled means
    Thank you
    PalspaceWhat does you subject line have to do with your question?
    The difference between a stored proc and a prepared statement is mainly this.
    A stored proc is stored in the database server permanently and can be used and re-used from a different connections.
    A PreparedStatement is not valid across connections.
    Stored procs are almost always precompiled. (I am just hedging a bit here just in case but you can consider it 100%)
    PreparedStatements MAY be precompiled. Hard to say.
    Precompiling means at least one of and perhaps all of the following depending on the database
    - The parsing of the SQL statement
    - The checking of the SQL against the data dictionary to ensure that the tables and columns referenced actually exist
    - The preparation of a query plan
    Last but not least Stored procedures may (and often do) contain more than simple queries but are in fact relatively complex programs written in a DB specific language (an offshoot of SQL of some sort).

  • Batch updates with callable/prepared statement?

    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797 states
    that "Using Batch updates with the callableStatement or preparedStatement is
    not supported". What does that actually mean? We have used both callable and prepared
    statements with the batch update in our current project (with the Oracle 817 db).
    It seems to run ok anyway.

    So the documentation should state that batch updates do not work ok in old versions
    of JDriver for Oracle, BUT work correctly with newer version. Additionally, batch
    updates work ok when used with Oracle supplied jdbc-drivers?
    "Stephen Felts" <[email protected]> wrote:
    Support for addBatch and executeBatch in the WLS Jdriver for Oracle was
    added in 7.0SP2.
    It was not available in 6.X or 7.0 or 7.0SP1.
    "Janne" <[email protected]> wrote in message news:3edb0cdc$[email protected]..
    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797
    states
    that "Using Batch updates with the callableStatement or preparedStatementis
    not supported". What does that actually mean? We have used both callableand prepared
    statements with the batch update in our current project (with the Oracle817 db).
    It seems to run ok anyway.

  • Performance of Stored procedures against Prepared Statements

    What will be the exact difference in the performance between implementing stored procedures and prepared statements ?

    Short answer: it depends.
    There will probobaly be very little difference in performance difference for a sipmle insert / update etc.
    Multiple inserts / updates etc you will probobaly find faster with a stored procedure rather than n prepared statments as you only have to contact the database once vs n times.
    Hope this helps!

  • Oracle Prepared Statement and spaces in field

    I have a field that is defined as char(10). It has characters like '39' in it. When I select against it using standard SQL (where clause) I get results. When I use it in the where clause of a prepared statement it does not return any rows.
    If I have the field defined as char(2) the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39' the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39 ' the prepared statement returns no results.
    I really do not think this is a JDBC problem. However, since Oracle's site basically <expletive deleted>, I am hoping someone here has a solution.
    Thanks in advance if you can help.

    Let me clarify.
    I cannot remove the whitespace from the data in the database. I do not need the whitespace to do the query if I am not using a Prepared Statement. This seems to be a problem with the way Oracle is handling the prepared statement. (hence.. my thinking that this is really not a JDBC problem at all.. but I could be wrong.)

  • ? in SQL Queries and not using prepared statements

    Using EclipseLink 1.1.1
    Prepared Statements are disabled
    In our production server something went wrong and one of our Read Queries started erroring. A DatabaseException was thrown and we log the "getQuery.getSQLString()" statement. We found this query in the logs:
    SELECT t1.ID, t1.NAME, t1.DESCRIPTION, t1.EXTREFID, t1.STYLESHEET, t1.DDSVNVERSION, t1.FIRSTNAME, t1.LASTNAME, t1.EMAILADDR, t1.PHONENUMBER, t1.ADDRESS, t1.ADDRESS2, t1.CITY, t1.STATE, t1.POSTALCODE, t1.COUNTRY, t1.ADMINACCTNAME, t1.HASDOCUMENTS, t1.HASTIMEDNOTIFICATIONS, t1.STATUS, t1.ENTRYDATE, t1.EVALEXPDATE, t1.LASTREMINDDATE, t1.FULLUSERS, t1.LIMUSERS, t1.REQUSERS, t1.ISENTERPRISE, t1.EXPDATE, t1.ISDISABLED, t1.DISABLEDDATE, t1.NEEDLICENSEAGREEMENT, t1.ISWARNINGDISABLED, t1.LOCALE, t1.TIMEZONE, t1.CURRENCY, t1.DOMAIN, t1.DOCUMENTSIZE, t1.EXTRADOCUMENTSTORAGE, t1.ONDEMANDOPTIONS, t1.SSOTYPE, t1.RESELLERID, t1.ACCOUNTREPID, t1.LASTUSAGEREPORTDATE, t1.NEXTUSAGEREPORTDATE, t1.USAGEREPORTATTEMPTS FROM T_SSOOPTIONS t0, T_CUSTOMERS t1 WHERE *((((t0.SSOENABLED = ?) AND (t1.SSOTYPE IN (?, ?))) AND (UPPER(t1.DOMAIN) = ?)) AND (t0.CUSTOMERID = t1.ID))*
    Notice the values weren't entered into the where clause. We had to bounce the application to fix the problem. I've never seen this before. I've added more debugging statements to the code - so if this happens again in the future I'll have more information to report on. In the mean time I'm wondering if anyone else has every seen a problem of this nature.

    Database error due to invalid SQL statement.
    I don't have a stack, we were catching the exception and not printing the stack :(
    Like I mentioned in my first post, I added more debugging code (e.printStackTrace()). I understand this is hard to track down without more information. I was just hoping you guys had seen something like this before and had any insight. Like I mentioned before: this is on our production server. I've never seen this type of error before. That particular server (we run in a cluster mode) had been up for several days and then started generating that error. IT bounced the node and everything went back to normal. We have been using toplink for about 5 years now and have never seen this problem, until August 3rd 2009. The only thing that has changed recently is our migration from toplink 10 to EclipseLink. I was wondering if anyone knows if anything had changed in EclipseLink/toplink 11 with the generation of SQL queries.
    I'll keep looking. There is more debugging code in there now. Since the error was "Database error due to invalid SQL statement" this implies the SQL was generated, exited that part of the code and was sent to the db where it failed. I'm afraid the printStackTrace won't help if this error happens again.

  • Pooling Prepared Statement and Resultset

    Is their any mechanism in Weblogic by which we can pool prepared statements and
    resultset.

    Yes you can cache prepared statements. The connection pool will
    automatically cache the prepared statements (10 prepared statement was the
    limit in previous so you may want to write some startup class to load the
    imp prepared statements.). When you reuse the prepared statement the
    connection pool will pick it from its prepared statement cache. In 6.1 you
    can configure the number of prepared statements that you want to cache.
    But you cannot have multiple resultsets open for the same statement object.
    You can have cache rows though.
    Please search the bea newsgroups for more info. There are a bunch of posts
    that will be helpful to you.
    http://search.bea.com/weblogic/gonews/
    sree
    "hogan" <[email protected]> wrote in message
    news:3bd9cf88$[email protected]..
    >
    Is their any mechanism in Weblogic by which we can pool preparedstatements and
    resultset.

  • Statement,Prepared Statement and callable statement

    Hi,
    Please let me know in which scenario we are using Statement,Prepared Statement and callable statement.
    and which is efficient one among the above.
    Thanks in advance

    Welcome to the forum!
    >
    Please let me know in which scenario we are using Statement,Prepared Statement and callable statement.
    >
    We don't know what scenario you are using those in or if you are using them at all. Are you asking what they are?
    For document related questions you should consult the documentation or use your favorite search engine to get information.
    See the Java Tutorial
    http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html
    >
    The main feature of a PreparedStatement object is that, unlike a Statement object, it is given a SQL statement when it is created. The advantage to this is that in most cases, this SQL statement is sent to the DBMS right away, where it is compiled. As a result, the PreparedStatement object contains not just a SQL statement, but a SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement SQL statement without having to compile it first.
    >
    The Javadocs for your Java SDK have the API for each of those classes and a description of what they are. And the Oracle JDBC Developer Guide has extensive information on how to use them.
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/toc.htm

  • Prepared Statement and DEFAULT identifier

    Does anyone know how to pass the identifier DEFAULT to a PreparedStatement?
    I am processing a text file to import into a database table (Oracle 9i) via JDBC. The user is able to configure what will happen if the data in the file doesn't match the types required by the database and so I do a quick check that the data is of the right type before it gets to the database. The user can choose to have the invalid value replaced with the default associated with that field (as configured on the database table). Eg. Table setup is
    CREATE TABLE "TEST1" (
    "TESTFIELD1" VARCHAR2(40 byte),
    "TESTFIELD2" VARCHAR2(40 byte) NOT NULL,
    "TESTFIELD3" NUMBER(30, 10) DEFAULT 777)
    sample data of 'abc', 'def', 'www' should therefore end up as 'abc', 'def', 777
    The problem I have is that I'm using a PreparedStatement to do the INSERTs (there could potentially be thousands of them).
    The following SQL is what I'm trying to emulate...
    INSERT INTO table (field1, field2, field3) VALUES ('abc', 'def', DEFAULT);
    BUT, I am using a PreparedStatment via JDBC with bind variables ...
    pstmt = con.prepareStatement("INSERT INTO table (field1, field2, field3) VALUES (?, ?, ?)");
    ps.setString(1, "abc");
    ps.setString(2, "def");
    ps.setsomething(3, something); <- what goes here?
    I have no idea what to put in the "something" bits so that DEFAULT is passed through. I obviously can't use setString(3, "DEFAULT"); as I'll just get an Oracle type mismatch error.
    I realise that I could just leave out the 3rd variable and the default would be inserted automatically - but because some of the rows in the input file may have a valid value for field3 I don't always want the default value. Using the straight SQL is not an option due to the performance (or lack thereof).
    Any ideas would be greatly appreciated! Thanks!

    As for the best of my knowledge if you set the value to be null in the prepared Statement while setting that
    for insert statement internally it is set to DEFAULT in ORACLE..
    More over i thought that this will be usefull for u..
    setNull
    public void setNull(int paramIndex,
    int sqlType,
    String typeName)
    throws SQLExceptionSets the designated parameter to SQL NULL. This version of the method setNull should be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.
    setNull
    public void setNull(int parameterIndex,
    int sqlType)
    throws SQLExceptionSets the designated parameter to SQL NULL.
    Note: You must specify the parameter's SQL type.
    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    sqlType - the SQL type code defined in java.sql.Types
    Throws:
    SQLException - if a database access error occurs
    ALL THE BEST

Maybe you are looking for

  • Problems with examples on WLS7.0 / RedHat8.0

    Hi all, I installed an evaluation copy of WebLogic/7.0.2.0 on a RedHat 8.0 Linux Box. I got some problems with the examples: The First problem was the copyright character in the index.jsp files I had to change the character with "©" in the following

  • Chart legend fails to print correctly

    When I print the front panel of my vi, the text in the chart legend is not visible on the printed document.  I have tried changing the font and style of the text in the legend, but that usually causes the program to crash.  I am using Labview 8.5.1 a

  • Rough cuts from Prelude lack audio source

    Hey everyone, this is my first project with a Prelude to Premiere Pro workflow and so far everything worked just fine. Although after creating a couple of rough cuts in Prelude and sending them to Premiere Pro I am experiencing a problem with the imp

  • SQL Developer (1.1.0.22.71) problem: SQL Developer crashes on connect

    Just downloaded latest sqldeveloper release (full release - 74MB). I am using windows XP laptop. When I tried to use connection using TNS connection type with connect identifier (trying to use OID based name resolution). The test button showed succes

  • SMTP message transfer with Forte'

    Hi, We are exploring a number of ways to transfer data from a business partner through a secure extent circuit. Since I have been reading a few messages regarding SMTP file transfer (send), I was wondering if anyone has any experience in writing a Fo