PreparedStatement Object Query

Hi,
If i use the same PreparedStatement object for two queries, will it cause any issues.
Example:
//start program
PreparedStatement ppt = null;
ppt = some query;
ppt.executeUpdate();
if i try to use the same object for other query, will it cause any problem?
ppt = anotherquery
ppt.executeUpdate();
//end program
Thanks in Advance

use same no problem
but before this u have to store results in ResultSet objects
so u have to create two ResultSet objects
thank u

Similar Messages

  • Same preparedstatement object for different queries.. ?

    Actually I m getting same preparedstatement object for many queries in a for loop..In this scenario its not working properly..Suppose like dis..
    connection con.setAutoCommit(false);
    PreparedStatement prepStmt = con.prepareStatement(
    "UPDATE DEPT SET MGRNO=? WHERE DEPTNO=?");
    prepStmt.setString(1,mgrnum1);
    prepStmt.setString(2,deptnum1);
    prepStmt.addBatch();
    PreparedStatement prepStmt = con.prepareStatement(
    "UPDATE EMP SET EMPNO=? WHERE DEPTNO=?");
    prepStmt.setString(1,empno1);
    prepStmt.setString(2,deptnum2);
    prepStmt.addBatch();
    Whether we can take same preparedstatement object for different query..??Its not giving any error but its not updating all the records but only the last one...
    Any solution..

    kriti123 wrote:
    Actually I m getting same preparedstatement object for many queries in a for loop..In this scenario its not working properly..Suppose like dis..
    Ignore all of the above.
    You are using a batch.
    There is a specific idiom for that. You create the statement once and then keep calling the appropriate methods on it to load and then execute the batch, and check errors.
    When done you close it. If you need commit you are going to need to deal in blocks.
    If you have a large volume of data then database import tools are very likely to be substantially faster.

  • How To change the ADF View Object  query where-clause at RunTime?

    I am trying to create a simple display page which will display user data (username, assoc_dist_id, assoc_agent_id, status , etc). The User data is stored in a database table and i am using an ADF Read Only table based on the View Object to display the data on the JSF page.
    However, i want to display only the users that a particular person accessing the page has the AUTH LEVEL to see. e.g. If the person accessing the page is an 'ApplicationAdministrator' then the page should display all users in the table, If its a 'DistributorAdministrator' then the page should display only users associated with that Distributor (i.e. assoc_dist_id = :p_Dist_id ) and If its an 'AgentAdministrator' , then the page should display only users associated with that Agent ( i.e. assoc_agent_id = :p_Agent_id).
    Currently my af:table component displays all the users in the table because the query for the view object is (select * from users) . However, i want to use the same viewobject and just set the where-clause at runtime with the appropriate parameter to restrict the dataset returned.
    Do anyone knows how to accomplish this ?

    David,
    See the custom method initializeDynamicVariableDefaults() in the SRViewObjectImpl.java class in the FrameworkExtentions project in the SRDemoSampleADFBC sample application. You can find out how to install the demo if you haven't already from the ADF Learning Center at:
    http://www.oracle.com/technology/products/adf/learnadf.html
    This class is a framework extension class for view objects that adds a neat, generic feature to be able to dynamic default the value of named bind variables. You can read more about what framework extension classes are and how to use them in Chapter 25, "Advanced Business Components Techniques" of the ADF Developer's Guide for Forms/4GL Developers, also available at the learning center above.
    It is an example of generic framework functionality that "kicks in" based on the presence of custom metadata properties on a named bind variable. See section 25.3.3 "Implementing Generic Functionality Driven by Custom Properties" in the dev guide for more details. Using this sample code, if you add a bind variable to a view object, and define a custom metadata property named "DynamicDefaultValue" on that bind variable, and set this custom metadata property to the value "CurrentUser", then that bind variable will have its value dynamically defaulted to the name of the authenticated user logged in. If instead you set this custom property to the value "UserRole", then the bind variable will be set to the comma-separated string containing the list of roles that the authenticated user is part of.
    Once you've created a framework extension class for view objects like this, you can have the view objects you create inherit this generic functionality.See section 25.1.4 "How to Base an ADF Component on a Framework Extension Class" in the dev guide for more info on this.
    By adapting a technique like this (or some idea similar that better suits your needs) you can have your view object query contain bind variables whose values automatically take on the defaults based on something in the user-session environment.

  • View object query bind variable

    I have a bind variable in my view object query and "Required" is unchecked for it. Due to this JUnits are failing with the Missing IN or OUT parameter error. If I set the bind variable as required, the JUnits run fine.
    But this bind variable is also used in several view criterias where it is set as Optional. So if I set the bind variable in the view object query as Required, will it affect the view criterias as well?

    check https://blogs.oracle.com/jdevotnharvest/entry/the_infamous_missing_in_or

  • Business object query panel

    hi all,
    iam new to crystal reports.
    can u guide me how to create query in business object query panel in crystal reports
    using two table in universes.
    Regards.
    Vijender

    If you already have the universe exported to server then create new connection in crystal and select universe and connect to server and select the universe from server. Once you select the universe it popsup query panel, here you can drag what all the fields that you want to display in crystal and also you can add filters in the query panel. Once you create the query add that query to crystal and run the report.
    Regards,
    Raghavendra

  • More than 1 preparedStatement  object using batch update

    Hey how can I execute more than 1 preparedStatement object using batch update..Pls explain with a code(java)
    Thanks

    // turn off autocommit
    con.setAutoCommit(false);
    PreparedStatement stmt = con.prepareStatement(
         "INSERT INTO employees VALUES (?, ?)");
    stmt.setInt(1, 2000);
    stmt.setString(2, "Kelly Kaufmann");
    stmt.addBatch();
    stmt.setInt(1, 3000);
    stmt.setString(2, "Bill Barnes");
    stmt.addBatch();
    // submit the batch for execution
    int[] updateCounts = stmt.executeBatch();
    search in google for more information

  • Help ::Object Query Langauge

    I have to give the object query language to solve some problems can any one help me with this?

    Hi
    <b>HELP_OBJECT_SHOW_FOR_FIELD</b>This function module displays the data element documentation for components of any structure or database table from the ABAP Dictionary. You pass the name of the component and structure or table to the import parameters FIELD and TABLE.
    Refer:
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbad0435c111d1829f0000e829fbfe/content.htm
    Regards
    Ravish Garg
    <b>
    *reward if useful</b>

  • Object Query Language (OQL) Support ?

    I know Toplink has an "ExpressionBuilder" type querying
    But does Toplink support Object Query Language (OQL)
    Example :
    Something like this ?
    // perform query
    OQLQuery query = new OQLQuery(
    "select x from Person x where x.name = \"Doug Barry\"");
    Collection result = (Collection) query.execute();
    Iterator iter = result.iterator();
    Thanks
    Ratheesh

    Ratheesh,
    TopLink does not support OQL. We offer query support through the following 5 options:
    1. EJB QL - for both Entity Beans (CMP/BMP) and Java objects
    2. TopLink Expressions - Object based query API
    3. SQL calls
    4. Stored procedure calls
    5. Quey by example
    Doug

  • Issue with View object query

    Hi,
    I have extended my controller to add an additional condition to the view object query where I appen an add condition.If there is any kind of exception the add condition keeps on appending without refreshing the query to the orginal one.I have to clear the cache to be able to fix it
    below is the peice of code.What should I do to be able to get the original query or refresh it because when i do a getQuery it keeps giving me the query with the earlier condition that I appended and again appends the new condition.
    strQuery = oaviewobjectimpl.getQuery();
    oaviewobjectimpl.setQuery(strQuery+" AND MtlCategoriesKfv.CONCATENATED_SEGMENTS = '"+strCategory+"'");
    RequisitionAMImpl requisitionamimpl1 = (RequisitionAMImpl)oapagecontext.getApplicationModule(oawebbean);
    OAViewObjectImpl oaviewobjectimpl = requisitionamimpl.getReqCategoryVO();
    String strQuery = oaviewobjectimpl.getQuery();
    oaviewobjectimpl.setQuery(strQuery+" AND MtlCategoriesKfv.CONCATENATED_SEGMENTS = '"+strCategory+"'");
    oaviewobjectimpl.setWhereClauseParams(null);
    oaviewobjectimpl.setWhereClauseParam(0, oapagecontext.getCurrentLanguage());
    if(oapagecontext.isLoggingEnabled(1))
    oapagecontext.writeDiagnostics(this, "oaviewobjectimpl.getQuery() "+oaviewobjectimpl.getQuery(), 1);
    oaviewobjectimpl.executeQuery();
    oaviewobjectimpl.last();
    if(oapagecontext.isLoggingEnabled(1))
    oapagecontext.writeDiagnostics(this, "oaviewobjectimpl.getFetchedRowCount() "+oaviewobjectimpl.getFetchedRowCount(), 1);
    ReqCategoryVORowImpl reqcategoryvorowimpl= (ReqCategoryVORowImpl)oaviewobjectimpl.first();
    Number categoryId = reqcategoryvorowimpl.getCategoryId();

    user610276 ,
    Y don't u make a custom VO, as you are doing set query, i expect ur changing entire query of seeded VO, better to use custom VO here and attach it to required beans progrmatically.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to print PreparedStatment object in console

    Dear All
    i am using PreparedStatment for inserting data into a table, in my local system it is working fine, but after deploying in JBoss(Server) it is throwing "invalid column type" error. In order to check i tried to print in the JBoss console but i am unable print in the console, kindly help me regarding this.
    The code which i used is:
    PreparedStatement stmtPrep = conn.prepareStatement(sql);
    try {
    stmtPrep.setObject(1, number);
    stmtPrep.setObject(2, (String) passList.get("PlantCode"));
    stmtPrep.setObject(2, (String) passList.get("PlantExt"));
    stmtPrep.setObject(3, ls_per_ord_qty_ind);
    stmtPrep.setObject(4, ls_price);
    stmtPrep.setObject(5, (String) inList.get(4));
    stmtPrep.setObject(6, (String) List.get("txtStoreLoc"));
    stmtPrep.setObject(7, (String) List.get(1));
    h = (String) List.get("Price");
    float unit = Float.valueOf(h.trim()).floatValue();
    stmtPrep.setFloat(8, unit);
    System.out.println(">>>Query is>>>>>"+stmtPrep);
    Can any one guide me how to print in JBoss console this stmtPrep and check all the values that i am passing r correct r not.
    but it is throwing like this:
    15:16:30,686 INFO [STDOUT] >>>Query is>>>>>org.jboss.resource.adapter.jdbc.Wrap
    pedPreparedStatement@1056bdd

    sasikrishna wrote:
    Dear All
    i am using PreparedStatment for inserting data into a table, in my local system it is working fine, ok.
    but after deploying in JBoss(Server) it is throwing "invalid column type" error. That would seem to be a database problem to me. Schema specifically.
    In order to check i tried to print in the JBoss console but i am unable print in the console, Why does it matter since it will not help you?
    Your code specifically details the object types that you are setting.
    Presumbly the 'sql' is just a hard coded value.
    Consquently the conclusion is that the database on your local box versus the deployment is different. And nothing that you print in JBOSS will help you discover what the difference is. You need to look at the 'sql' and determine the entities from that and then compare them in the schema for both places.
    check all the values that i am passing r correct r not.As noted if that isn't a security violation for your application then you are left with the following.
    - Drivers do not necessarily create SQL.
    - If they do AND the driver is up to date then there is a method (look for it in the javadocs) that will return it
    - If not you should use a jdbc wrapper proxy that consumes the data for you. This might be better even if the driver does it.

  • Decode statement in Select line of a View Object Query

    I attempted to create a view object in expert mode with a customized query.
    The query had a decode statement in the select line of the query. The view
    object compiled correctly but gave an error when run.
    ex: select .... decode(CrpSchools.SCHOOLS_ID,null,CrpCustSchools.SCHOOL_NAME,CrpSchools.SCHOOL_NAME) SCHOOL_VALUE, ...
    from ....
    where ....
    The error was that school_value does not exist in the statement. I got the error when
    doing a vo.executeQuery().
    When I removed the decode statement everything worked correctly. Does anyone know if
    the decode statement cannont be used in the select line of a query in a view object?
    Or maybe I was linking the query column (SCHOOLS_ID) up to the view attribute (SCHOOL_VALUE) incorrectly in the
    Attribute Mappings tab of the VO wizard?

    There should be no problem using a DECODE() statement, provided that you've aliases the column as you have done.
    At design time, if you click on the (Test) button, does your query test ok?
    Are you by chance applying a custom where clause at runtime?
    If so, are you saying:
    setWhereClause("yourtable.column_alias = ?";
    or are you doing:
    setWhereClause("column_alias = ?";
    for an expert-mode query, you'll need to use the latter syntax.

  • Pass parameter from jsf to view object query

    Hi,
    i have requirement where user id is captured when user logs in in a session bean.How do I pass this parameter to bind variable in query?
    thanks,
    Mat

    Amit's second link : Setting bind variable for a view object
    should hold answers for you.
    Ypu can also visit : http://groundside.com/blog/DuncanMills.php?title=adf_executing_code_on_page_entry_1_servi&more=1&c=1&tb=1&pb=1
    The general idea is this :
    Get the username (you mentioned portal, so after portal authenticates the user is the username available in a session scoped managed bean ? You would need to access this somehow because your query needs it., preferrably by EL)
    create am AM method to set the bind parameter to the Vo and execute it. The method is automatically exposed to the DataControl.
    Create a method binding in your page def for the method. in the parameters for the method, use the EL to get the username, eg: #{sessionScope.frameworkBean.username} (you could also create a binding for executeWithParams, but I hav'nt done this in a while and dont remember the exact process )
    Now create an executable for the method binding you created. (the executable ensure that this method is called at pageload, and set you refresh condition appropriately)
    Go to the properties
    Edited by: Jeevan Joseph on Jan 13, 2011 2:44 PM

  • Error in "My Objects"-Query

    Hi Experts,
    using Queries in "My Objects"-Section in Document Work Center (using NWBC 3.0) creates an error:
    Last query refresh failed due to internal errors; contact your admin.
    Message no. POWL019
    Diagnosis
    Most possible cause is an exception triggered by the respective business object type feeder class.
    System Response
    The system returned the following error message:
    CREATE DATA: The specified type is no valid data
    Procedure
    Contact your admin, providing him the system error message and your user ID.
    Procedure for System Administration
    Check transction ST22 for the returned system message with the respective user ID.
    What happens here? Can anyone help?

    k reddy,
    most likely is that someone has changed the objects before you, or they are stored as local objects (development class $tmp)
    why don't you try to look for the request number that it's locked against (i think you're given the request number right?) via SE09, and then remove the objects from the other request/s manually. if it's the latter problem, use SE03 and choose the option to change development classes of objects, and then change them manualy, assigning them to the right dev. class and transport request number/s.
    it's a difficult process, and i wish i could suggest a better option, but i don't have that at the moment. =(
    don't forget to assign points if it still helps though.
    ryan.

  • PreparedStatement Synchronization Query

    Hi All,
    I hope this is the right place to post this query (heh)! In a Java Webapp I have around 30 PreparedStatement(s) stored as global variables. As it is possible that some of the PreparedStatement(s) will be executed by multiple users concurrently from different pages (i.e. sections of the code), in addition to the usual synchronization tags I have volatile boolean values to check whether a PreparedStatement is currently in use to prevent concurrent execution. For example:
    //  PreparedStatement is global, ResultSet is local.
    synchronized(this) {
      while (flagRaised) {
         try {
           wait();
         } catch (InterruptedException e) {
           // do nothing.
       flagRaised = true;
       try {
         preparedStatement.setString(1, "Pears");
         localResultSet = preparedStatement.executeQuery();
       } catch (SQLException e) {
         // log the problem
       flagRaised = false;
       notifyAll();
    }I believe that this is necessary for any "mutator" statements where I'm using "setXXXX", but if I had a statement that returned an entire table would I need to implement any additional synchronization code? For example could I simply have:
    localResultSet = preparedStatement.executeQuery(); // where the PreparedStatement returns a table.with no synchronization/volatile variables?
    Thanks in anticipation,
    Simon

    I fail to see why the above is necessary. Think of what you are doing: caching a PreparedStatement. Why?
    PreparedStatement, out of the box with a decent JDBC driver, will cache the parsed SQL query. Further, most RDBMS will also perform their own native cachine of query plans. (I will leave out the considerations of RDBMS cached execution plans, though they are also valid to the discussion). You are adding a level of pooling above and beyond what the vendor offers. This might be necessary if your own system, but have you benchmarked this? Do you 'know' the middleware parse of a PreparedStatement is your actual scaling bottleheck. IMO, this is a rare situation.
    Rather, understand what both your RDBMS and your JDBC driver's use of PreparedStatement already offer you. Premature optimization is the root of most software evil, at least according to Knuth. Sure you are not contributing to the same?
    - Saish

  • Getting a dataprovider object QUERY property with JavaScript

    Hi, I'm trying to get the QUERY property of a DataProvider Object, but can't seem to get it. Can anyone tell me if this code is ok?
    Thanks!
    <object>
    <param name="OWNER" value="SAP_BW"/>
    <param name="CMD" value="SET_DATA_PROVIDER"/>
    <param name="NAME" value="DP1"/>
    <param name="QUERY" value="ZGZMPASDPL_SR21_CNRTY_DASH_01"/>
    <param name="INFOCUBE" value="ZMPASDPL"/>
    DATA_PROVIDER:             DP1
    </object>
    var currentQuery = SAPBWGetItemProp("DP1");
    var queryName;
    if (currentQuery != null)
    {   for(i=1; i<currentQuery.length; i++)
            {  if (currentQuery<i>[0] == "QUERY")
                   queryName = (currentQuery<i>[1]);

    Hi Kenneth,
    copy&paste the attached webtemplate coding in your WAD...
    regards Jens
    <HTML>
    <!-- BW data source object tags -->
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_DATA_PROVIDER"/>
             <param name="NAME" value="DATAPROVIDER_1"/>
             <param name="QUERY" value="ZGZMPASDPL_SR21_CNRTY_DASH_01"/>
             <param name="INFOCUBE" value="ZMPASDPL"/>
             DATA_PROVIDER:             DATAPROVIDER_1
    </object>
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_PROPERTIES"/>
             <param name="TEMPLATE_ID" value="Z_GETQUERYID"/>
             TEMPLATE PROPERTIES
    </object>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control">
    <TITLE>BW Web Application</TITLE>
          <link href= "/sap/bw/Mime/BEx/StyleSheets/BWReports.css" type="text/css" rel="stylesheet"/>
    </HEAD>
    <BODY>
    <span style="DISPLAY: none; VISIBILITY: hidden" id="queryname">
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TEXTELEMENTS_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_TEXT_ELEMENTS"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="GENERATE_CAPTION" value=""/>
             <param name="BORDER_STYLE" value="NO_BORDER"/>
             <param name="SHOW_COMMON_ELEMENTS" value=""/>
             <param name="SHOW_FILTERS" value=""/>
             <param name="SHOW_VARIABLES" value=""/>
             <param name="ELEMENT_TYPE_1" value="COMMON"/>
             <param name="ELEMENT_NAME_1" value="REPTNAME"/>
             <param name="ONLY_VALUES" value="X"/>
             ITEM:            TEXTELEMENTS_1
    </object>
    </span>
    <P></P>
    <P><object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TABLE_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             ITEM:            TABLE_1
    </object></P>
    <script language="JavaScript">
    var queryid = document.getElementById('queryname').innerHTML;
    alert(queryid);
      </script>
    </BODY>
    </HTML>

Maybe you are looking for