How to use prepared statement by Application Module on ADF?

Hello
i am using a prepared statement on the view side of my project,
this is my code, i'm not sure about using this code.
AppModuleGFTImpl am = (AppModuleGFTImpl) Configuration.createRootApplicationModule(amDef,config);
try {
ps =am.getDBTransaction().createPreparedStatement("Select * from XXXXXX where kullanici_id=? and sifre=?",0);
ps.setString(1, kullanici);
ps.setString(2, sifre);
rs = ps.executeQuery();
if (rs.next()) {
girebilir = true;
} else {
girebilir = false;
ps.close();
rs.close();
//am.getDBTransaction().closeTransaction(); ? I'm not Sure
//Configuration.releaseRootApplicationModule(am, true); ? I'm not Sure
Is it True? How we use this code on the project view side? Must we close Transaction, or release application Module.
thanks for interest.
sorry my english.

Hello, for the SP you can use something like this in your application module
  private static final String BULKSTAMMENN =
    "begin IVA_OWNER.IVA_UI_ALGEMEEN_PCK.USM_SNELLE_INVOER_GUI( P_RLE_ID => :1, P_AANTAL => :2, P_OJR_JAAR => :3, P_RAS_ID => :4, P_TOELICHTING => :5, P_SUCCES => :6 ); end;";
public void bulkStamen ( int rasId, int telerId, int jaar, int aantal, String toelichting ) {
    CallableStatement bulkStamenSP = null;
    try {
      bulkStamenSP = getDBTransaction().createCallableStatement( BULKSTAMMENN, 0 );
      bulkStamenSP.setInt( 1, telerId );
      bulkStamenSP.setInt( 2, aantal );
      bulkStamenSP.setInt( 3, jaar );
      bulkStamenSP.setInt( 4, rasId );
      bulkStamenSP.setString( 5, toelichting );
      bulkStamenSP.registerOutParameter( 6, Types.VARCHAR );
      bulkStamenSP.executeUpdate();
    } catch ( Exception e ) {
      log.warning( "Aanroep naar " + BULKSTAMMENN + " gefaald, " + e.getMessage() );
    } finally {
      if ( bulkStamenSP != null ) {
        try {
          bulkStamenSP.close();
        } catch ( Exception e ) {
          log.warning( e.getMessage() );
    log.info( "Stammen bulk uitgevoerd voor " + rasId + " " + telerId + " " + jaar + " " + aantal + " " +
              toelichting );
  }You can then drag this method onto your page or right into your task flow if your using JDev 11.
Also you can access it from a backing bean although the methods above are preferred
-Anton

Similar Messages

  • How to use prepared statement - For Everyone Help

    public String count()
    int count = 0;
    String fetchsize = "";
    try
    Connection conn = getOADBTransaction().getJdbcConnection();
    Statement statement = conn.createStatement();
    String Query = "select count(*) count from fnd_lookups where lookup_type like 'SAPE_BILL_TO_SHIP_TO_UPDATE'";
    ResultSet resultset = statement.executeQuery(Query);
    while (resultset.next())
    count = (int)resultset.getInt("count");
    fetchsize = ""+count;
    catch(Exception e)
    return fetchsize;
    }

    Hi,
    we can use prepare statement in Co....
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    try
    PreparedStatement prpdStmt1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("select full_name from per_all_people_f where person_id='"+empid+"' ");
    ResultSet rs=prpdStmt1.executeQuery(); //Cursor fetch row
    while(rs.next())
    empname=rs.getString(1);
    catch(Exception e)
    System.out.println("Exception is"+e.getMessage());
    t1.setValue(pageContext,empname);
    Thanks
    nani

  • How to use prepared statements with a single id

    Here is the code I am having trouble with:
    String sqlb = "INSERT INTO books.book(title)" +
                             "VALUES(?)";
                   String sqla = "INSERT INTO books.author(name,date_of_birth)" +
                             "VALUES(?,?)";
                   PreparedStatement psb = c.prepareStatement(sqlb);
                   PreparedStatement psa = c.prepareStatement(sqla);
                   psb.setString(1,book.getTitle());
                   psa.setString(1,author.getName());
                   psa.setString(2,author.getDate());
                   m = psb.executeUpdate();
                   n = psa.executeUpdate();
    After placing two book/Author objects into the database I get a table that looks something like this:
    0 AGreatBook Joe Bloggs 08-10-83
    1 BGreatBook Joe Bloggs 08-10-83
    2 AGreatBook John Smith 12-12-65
    3 BGreatBook JohnSmith 12-12-65
    Clearly this is not correct I want this:
    0 AGreatBook Joe Bloggs 08-10-83
    1 BGreatBook John Smith 12-12-65
    By the way I have placed a foreign key in book table
    Anyone know how to do this? (I am using postgres)
    regards

    http://forum.java.sun.com/thread.jspa?threadID=726820&tstart=0
    http://forum.java.sun.com/thread.jspa?threadID=726823&tstart=0

  • How to Insert Character using Prepared statement

    Hi All,
    Can anyone let me know how can I insert character using prepared statement.
    Thanks
    Sameer

    In the future JDBC related questions should be posted into the JDBC forum.
    Can you please provide some more information about what you are trying to do? It isn't clear to me. Are you trying to update a CHAR field?

  • Query slow when executing using prepared statement compared to sqlDeveloper

    Oracle version is 10.2.0.1.0.
    I have got a query which when submitted from java code using prepared statement and parameter substitutions, takes more than 20 seconds to give results.
    I can see this SELECT sql sitting there when I run Monitor Sessions through sqlDeveloper, with its wait time increasing and then finally getting through. During that time no other SQLs are waiting.
    DURING THAT TIME then I am able to run the same query (with values included) multiple times using sqlDeveloper, and it gives results in no time.
    Sqldeveloper connects using thin client using lib provided by oracle in windows.
    Java code runs from linux and uses the thin client using lib provided by oracle in linux.
    Both are hitting the same DB running on a separate Linux machine.
    What could be the cause of this problem?
    What db parameters, queries should I run to identify the bottleneck?
    Edited by: user10390517 on Jun 14, 2010 3:06 AM

    Hi Rob,
    at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
    select sql_id
         , PLAN_HASH_VALUE
         , CHILD_NUMBER
         , EXECUTIONS
         , ELAPSED_TIME
         , USER_IO_WAIT_TIME
         , CONCURRENCY_WAIT_TIME
         , DISK_READS
         , BUFFER_GETS
         , ROWS_PROCESSED
      from v$sql
    where sql_id = your_sql_idRegards
    Martin

  • Using Application Module outside ADF Application context

    I am trying to run application module using a standalone java class. Trying to use Application Module outside ADF Application context.
    I have created a jar file on my standalone java class, and added my ADF application jar files to the classpath while running my standalone java file as a Jar file.
    I could connect to the application module and I am able to get the response from my application module.
    Below is the code I used to invoke my application module method from my standalone java class.
         public static void main(String[] args) {
              System.out.println("Testing .....");
             String jdbcURL = "jdbc:oracle:thin:@localhost:1521:XE";
             Hashtable env = new Hashtable();
             env.put(Context.INITIAL_CONTEXT_FACTORY, JboContext.JBO_CONTEXT_FACTORY);
             env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
             try {
                 Context ic = new InitialContext(env);
                 String defName = "com.org.model.BatchJobAppModule";
                 ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(defName);
                 ApplicationModule mbApplicationModule= (ApplicationModule)home.create();
                 mbApplicationModule.getTransaction().connect(jdbcURL, "HR", "HR");
                    ((BatchJobAppModuleImpl)mbApplicationModule).connectToDatabase();
             } catch (NamingException ne) {
                 // TODO: Add catch code
                 ne.printStackTrace();
    {code}
    I am getting following messages.
    {code: warning}
    oracle.adf.share.ADFContext getCurrent
    WARNING: Automatically initializing a DefaultContext for getCurrent.
    Caller should ensure that a DefaultContext is proper for this use.
    Memory leaks and/or unexpected behaviour may occur if the automatic initialization is performed improperly.
    This message may be avoided by performing initADFContext before using getCurrent().
    To see the stack trace for thread that is initializing this, set the logging level of oracle.adf.share.ADFContext to FINEST
    Dec 14, 2012 10:16:37 PM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    SEVERE: java.io.FileNotFoundException: D:\satya\testPackage\.\config\jps-config.xml (The system cannot find the path specified)
    {code}
    I have another question regarding connecting to database.
    How to get connection from a datasource, to avoid supplying database credentials which will vary from one environment to another.
    Please let me know if any one has pointers.
    Thanks in advance.
    Regards,
    Satya
    Edited by: 921138 on Dec 14, 2012 9:20 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Thanks Shay for your response.
    When I run the standalone java class from jDeveloper 11.1.1.5.0, I am able to get application module and also able to get the out put from application module method. While running the java class jdev is exectung the class with javaw command. I tried to execute the same from commnd prompt, it didn't print anything on the command prompt. So I tried to execute java command with "java followed by class path" as below.
    set JAVA_HOME=C:\Oracle\Middleware\jdk160_24\jre
    set PATH=%JAVA_HOME%\bin;%PATH%
    java -classpath E:\poc\TestBatchJobClient\Project1\deploy\First.jar;E:\poc\BatchJobApp\Model\deploy\adf-share-base.jar;E:\poc\BatchJobApp\Model\deploy\adfm.jar;E:\poc\BatchJobApp\Model\deploy\BatchJobApp_Model.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\adf-share-support.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share.ca_11.1.1\adf-share-ca.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share.ca_11.1.1\adf-share-base.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\adflogginghandler.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\adfsharembean.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jmx_11.1.1\jmxframework.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jmx_11.1.1\jmxspi.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.idm_11.1.1\identitystore.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.model_11.1.1\adfm.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.model_11.1.1\bc4j-mbeans.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.model_11.1.1\bc4jwizard.jar;C:\Oracle\Middleware\oracle_common\modules\groovy-all-1.6.3.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.xdk_11.1.0\xmlparserv2.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.model_11.1.1\db-ca.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.model_11.1.1\jdev-cm.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.ldap_11.1.1\ojmisc.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\commons-el.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\jsp-el-api.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.share_11.1.1\oracle-el.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.javatools_11.1.1\resourcebundle.jar;C:\Oracle\Middleware\modules\javax.activation_1.1.0.0_1-1.jar;C:\Oracle\Middleware\modules\javax.mail_1.1.0.0_1-4-1.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.mds_11.1.1\oramds.jar;C:\Oracle\Middleware\modules\javax.servlet_1.0.0.0_2-5.jar;C:\Oracle\Middleware\modules\javax.jsp_1.2.0.0_2-1.jar;C:\Oracle\Middleware\jdeveloper\ide\macros\..\..\..\wlserver_10.3\server\lib\ojdbc6.jar;C:\Oracle\Middleware\oracle_common\jlib\commons-cli-1.0.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.bali.share_11.1.1\share.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.xmlef_11.1.1\xmlef.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.dms_11.1.1\dms.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.xdk_11.1.0\xml.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.javacache_11.1.1\cache.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.ucp_11.1.0.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.odl_11.1.1\ojdl.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.javatools_11.1.1\javatools-nodeps.jar;C:\Oracle\Middleware\modules\javax.management_1.2.1.jar;C:\Oracle\Middleware\modules\javax.management.j2ee_1.0.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.mds_11.1.1\mdsrt.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.ldap_11.1.1\ldapjclnt11.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-api.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-common.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-ee.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-internal.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-unsupported-api.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-manifest.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1\jacc-spi.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.pki_11.1.1\oraclepki.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.osdt_11.1.1\osdt_core.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.osdt_11.1.1\osdt_cert.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.osdt_11.1.1\osdt_xmlsec.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.osdt_11.1.1\osdt_ws_sx.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.iau_11.1.1\fmw_audit.jar;C:\Oracle\Middleware\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\Oracle\Middleware\oracle_common\modules\oracle.adf.security_11.1.1\adf-share-security.jar -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\wlserver_10.3\server\lib\DemoTrust.jks com.org.TestMyClass
    {code}
    I got the same old error.
    Regards,
    Satya                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Check the Row state in Application Module.

    Hi All,
    I have an EOVO in my page. Is there any way to check the row state in Application module??
    My requirement is if any row is created for the EOVO , just delete it.
    Please suggest suitable methods to fulfill this requirement...
    Regards,
    Tarun

    Yes, you can check the status of the rows of a VO in Application Module(AM)
    In AM, get the instance of the VO and loop through it's rows and check the status of the rows as
    In row you have a method called getNewRowState(). It will return values like Row.STATUS_INITIALIZDED etc.
    Check the javadoc of oracle.jbo.Row for possible values and explanations about the status.
    So ideally you have to write a condition as follows. This is a sample code..just use as a guide.
    if (row.getNewRowState() = oracle.jbo.Row.STATUS_INITIALIZED){
    row.remove();
    Regards,
    Peddi.

  • How to use Logical database in function module?

    I will create a function module in HR.
    but how to use Logical database  in function module ?  Logical database PNP always show screen.in function (RFC) code , it is a matter.

    You cannot attach the LDB to the main program of the function group.
    - So you may [SUBMIT|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=submit&adv=false&sortby=cm_rnd_rankvalue] a report which use the LDB and get back the data (export/import), by default in the syntax of SUBMIT the selection-screen will not be displayed
    - Use [LDB_PROCESS|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=ldb_process&cat=sdn_all], fill a structured table for selection, and get data back in another table
    - Use [HR function modules to read Infotypes|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=hrfunctionmodulestoread+Infotypes&adv=false&sortby=cm_rnd_rankvalue].
    Regards

  • How to use perform statements in sap scripts

    how to use perform statements in sap scripts . and pls send me one progam for this
    thnaks
    raja

    Hi Raja,
    <b>PERFORM</b> key work is used to include subroutine in sapscript form...
    But the processing is lttle bit different form the one we use in ABAP.
    Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
    Check out the example below to see how this is used..
    <b>Definition in the SAPscript form:</b>
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM
    / &BARCODE&
    <b>Coding of the calling ABAP program:</b>
    REPORT QCJPERFO.
    FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
    OUT_PAR STRUCTURE ITCSY.
    DATA: PAGNUM LIKE SY-TABIX, "page number
    NEXTPAGE LIKE SY-TABIX. "number of next page
    READ TABLE IN_PAR WITH KEY ‘PAGE’.
    CHECK SY-SUBRC = 0.
    PAGNUM = IN_PAR-VALUE.
    READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
    CHECK SY-SUBRC = 0.
    NEXTPAGE = IN_PAR-VALUE.
    READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
    CHECK SY-SUBRC = 0.
    IF PAGNUM = 1.
    OUT_PAR-VALUE = ‘|’. "First page
    ELSE.
    OUT_PAR-VALUE = ‘||’. "Next page
    ENDIF.
    IF NEXTPAGE = 0.
    OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
    ENDIF.
    MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    Hope this is clear to understand...
    Enjoy SAP.
    Pankaj Singh.

  • How to use a user defined function module in IP

    Hi All,
    Can you please guide me on how to use a user created function module in IP? My requirement is to have 2 exit function modules to be used in IP to load the falt file data into a cube..
    Regards,

    Hi,
    /people/marc.bernard/blog/2007/11/25/how-to-load-a-file-into-sap-netweaver-bi-integrated-planning-part-1
    thanks to Marc Bernard
    Regards

  • Problem in inserting to MS Access using prepared statement

    I am inserting a record in MS Access db and I am using prepared statement. I am encountering an error.... any help I would really appreciate it. So much time figuring out what the problem is....
    ConvertText contxt = new ConvertText();
    String bday = (String)cbYear.getSelectedItem() +
    cbMonth.getItemCount()+(String)cbDay.getSelectedItem();
    try{
    // load MySQL driver
    Class.forName(driver);
    // Setup connection to DBMS
    Connection conn = DriverManager.getConnection(url);
    // Create statement     
    Statement stmt     = conn.createStatement();
    PreparedStatement insertPersons = conn.prepareStatement(
            "INSERT INTO PERSONS VALUES(" +
         "FIRST_NAME               = ?," +
         "LAST_NAME              = ?," +
         "MIDDLE_NAME               = ?," +
         "NICKNAME              = ?," +
         "GENDER              = ?," +
         "MARITALSTATUS           = ?," +
         "AGE                    = ?," +
         "BIRTHDATE                   = ?," +
         "ADDRESS                  = ?," +
         "RES_PHONE_NUMBER        = ?," +
         "OFFICE_PHONE_NUMBER     = ?," +
         "CELL_NUMBER               = ?," +
         "COMPANY_NAME               = ?," +
         "EMAIL_ADDRESS               = ?," +
         "TIMESTAMP               = ?)"
              insertPersons.setString   (1, tfFirstName.getText());
              insertPersons.setString   (2, tfLastName.getText());
              insertPersons.setString   (3, tfMiddleName.getText());
              insertPersons.setString   (4, tfNickName.getText());
              insertPersons.setString   (5, (String)cbGender.getSelectedItem());
              insertPersons.setString   (6, (String)cbMaritalStatus.getSelectedItem());
              insertPersons.setInt      (7, contxt.formatStringToInt(tfAge.getText()));
              insertPersons.setDate     (8, contxt.formatStringToSQLDate(bday));
              insertPersons.setString   (9, tfAddress.getText());
              insertPersons.setString   (10,tfResPhoneNumber.getText());
              insertPersons.setString   (11,tfOffPhoneNumber.getText());
              insertPersons.setString   (12,tfCellNumber.getText());
              insertPersons.setString   (13,tfCompanyName.getText());
              insertPersons.setString   (14,tfEmailAddress.getText());
              insertPersons.setTimestamp(15, new Timestamp(System.currentTimeMillis()));          
              insertPersons.executeUpdate();
              conn.close();          
    JOptionPane.showMessageDialog(null,"Record Inserted!", "INSERT",
                        JOptionPane.INFORMATION_MESSAGE);
    }catch (SQLException ex){
    System.err.println("==> SQLException: ");
    System.out.println("Message:   SQL Exception");
    System.out.println("Message:   " + ex.getMessage ());
    System.out.println("SQLState:  " + ex.getSQLState ());
    System.out.println("ErrorCode: " + ex.getErrorCode ());
    JOptionPane.showMessageDialog(null, ex.getMessage() + ex.toString(),"Error", JOptionPane.INFORMATION_MESSAGE);
    }catch(Exception ex){
    }          ERROR Displayed:
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 30. java.sql.SQLException     

    Hi cruzdhel,
    Your SQL looks incorrect to me.
    I am not familiar with that syntax.
    I think it should be like this:
    PreparedStatement insertPersons =
    conn.prepareStatement("INSERT INTO PERSONS (FIRST_NAME," +
                                               "LAST_NAME," +
                                               "MIDDLE_NAME," +
                                               "NICKNAME," +
                                               "GENDER," +
                                               "MARITALSTATUS," +
                                               "AGE," +
                                               "BIRTHDATE," +
                                               "ADDRESS," +
                                               "RES_PHONE_NUMBER," +
                                               "OFFICE_PHONE_NUMBER," +
                                               "CELL_NUMBER," +
                                               "COMPANY_NAME," +
                                               "EMAIL_ADDRESS," +
                                               "TIMESTAMP)" +
    "values (?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?)");Hope this helps.
    Good Luck,
    Avi.

  • Advantages of using prepared statement..... ?

    can anyone please tell me that what r the advantages of using prepared statements.
    for eg in case if statement object is executed inside a for loop where query is executed multiple times the sql query is compiled outside loop and therefore compilation is done only once. which makes sense
    But if there the query is not executed multiple times then what is the real benifit of using prepared statement . because the statement object will be closed after executing the query.
    and a new statement object will be created when other user access the same code.
    please clearify my doubts
    thanks
    Pankaj

    Other advantages of using PreparedStatement:
    1. It's easier to create SQL that looks like "Select This, That, TheOther from Something where ID=? and Usage=?" than to try to generate that with string concatenations.
    2. You don't have to deal with escaping quote characters that happen to appear in strings you want to insert in your database.
    3. PreparedStatements can do some things that Statement can't, such as updating very large text columns.

  • How to use union statement with declare & set function?

    Hi Experts,
            i  have small query about how to use union statement with declare & set function?
    Example as below :
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]

    You have to create stored procedure in SQL only .
    Like u must have create for Crystal .
    You can execute procedure in query manager but you have to enter parameter manually..
    example
    Exec @Test '20140101' '20140501'
    Every time user has to enter it manually in yyyymmdd format in case of date parameters.
    Example
    Create Proc [@Test]
    as begin
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between
    between @Name and @Name2
    end

  • How to use CASE statement in WDA

    Hi All,
       Can any one Please expain me ' How to use CASE statement in Web dynpro ABAP? '
      Please give me an example also.
    Thanks in Advance !

    Hi,
    The usage of case statement in webdynpro is same as used in general ABAP.
    Data: l_id type string.
    l_id = wdevent->get_string( 'ID' ).
    case l_id.
    when 'BTN1'.
    when 'BTN2'.
    when 'OTHERS'.
    endcase.
    Regards,
    Radhika.

  • How to use collect statement for below

    data : begin of itab,
             n(3) type c,
          n1 type n,
          k(5) type c,
          end of itab.
    select n n1 from into itab table /zteest.
    *internal table has
    n      n1    k
    gar    100  uji
    hae    90   iou
    gar    90   uji
    hae    87   iou
    I want
    gar 190
    hae 177
    How to use collect statement as n1 is n ..?
    let me know..
    Thanks

    try this..
    DATA : BEGIN OF itab OCCURS 0,
    n(3) TYPE c,
    n1(3) TYPE p DECIMALS 2,
    k(5) TYPE c,
    END OF itab.
    itab-n = 'gar'.
    itab-n1 = 100.
    itab-k = 'uji'.
    COLLECT itab .CLEAR itab.
    itab-n = 'hae'.
    itab-n1 = 90.
    itab-k = 'iou'.
    COLLECT itab .CLEAR itab.
    itab-n = 'gar'.
    itab-n1 = 90.
    itab-k = 'uji'.
    COLLECT itab .CLEAR itab.
    itab-n = 'hae'.
    itab-n1 = 87.
    itab-k = 'iou'.
    COLLECT itab .CLEAR itab.

Maybe you are looking for