Proving prepared statements are being reused

How can I prove that a prepared statement from a JDBC driver is being reused / pooled ?
What essentially I want to do is to have prepared statements reused to reduce hard parsing ... but I also need to prove that the statements are being reused. If I query the statement in V$SQLAREA, the column PARSE_CALLS does not seem to be distinguish between hard parse and soft parse:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3204.htm#1126299
I am only interested for now in proving the just ONE statement is being reused ... which mean that the number of hard parses is very low compared to the number of soft parses for that ONE statement.
Regards,
jms
Message was edited by:
jms

Hi,
No, parse calls is all soft and hard parse together. What you would see, if used absolutely correctly, would be 1 hard parse per session and many executions.
But since v$sql is obviously not linked to v$session other than at the time of exection, you see the aggregated parse calls and executions for each cursor. So what you should see is parse calls go up relatively slowly to the number of exections.
However, you can see soft and hard parses using the v$sesstat and v$statname views so you can see soft and hard parses on a session by session basis, be these are again aggregated, so you can't see soft / hard counts per cursor, only the total for a session.
What I see a lot of the time is they don't get it quite right, so hard parses is low but soft parses are high, so they are still parsing when they don't need to, but at least they are binding and using shareable SQL, which is a step in the right direction.
When I say 'they', it is a generic reference to all Java/.Nyet programmers writing front end code where they just don't 'get' parsing and binding because it's just too complicated and hey, SQL Server isn't like this...!
HTH
Chris

Similar Messages

  • Oh my God Prepared Statements are about 80 times slower than multiple inser

    I am highly suprised that in my programme a normal statement os a lot faster than a Prepared Statement. I am posting below both the Programmes, in one I am using Prepared Statements and in another I am using normal Statements. My OS is Win NT My Database is SQL Server 7. THe progamme extracts data from a file and inserts records in the database. In the test case I had A file of about 1440 records ie. 1440 inserts are made to the database, The database table is very large ie. It has around 126 Columns.
    So for inserting 1440 record froma file the Prepared Statements take around 7 Minutes . And for reading the same file and inserting the same no of records in the same database normal Statements Take only about 7 seconds. Now the JAcva docs clearly Specify that when we need to use the same stmt many times it is better to use Prepared Satements < the results that I am Getting is clear and complete violation of what java docs say.
    Below is the code with Prepared Statements
    package mps.mpsPTLF;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.Calendar;
    import java.util.Date;
    import gen.genCommon.genConnectionPool.*;
    import gen.genCommon.*;
    public class PTLFProcessor
         private static clsLogFile moLogFile = new clsLogFile("");
         private gen.genCommon.genConnectionPool.SharedConnectionPool mConnPool = SharedConnectionPool.getInstance(2);
         FileReader fPTLF = null;
         BufferedReader brPTLF = null;
    //**************** Begin Constructor declaration ************************
    To intialize the class variables for new Fee
         public PTLFProcessor(String pathPTLF) throws GenException
              try
                   fPTLF = new FileReader(pathPTLF);
                   brPTLF = new BufferedReader(fPTLF);
              catch (Exception e)
                   throw new GenException("Error Accessing file : " + pathPTLF + " - " + e.toString(),e );     
    //**************** End  Constructor declaration ************************
         public void PTLFGetData() throws GenException
              char pcData[];
              int HEADERSIZE = 6;
              boolean pbEndOfFile = false;
              boolean pbisFirstBlock = true;
              int piBlocksize = 0;
              int piOffset = 0;
              int piRecordsize = 0;
              String psRecordContent = "";
              Connection pConn = null;
              try
                   String psInsSql=" INSERT INTO FILE_PTLF_IN ( " +
                                       " fpi_DAT_TIM , " +
                                       " fpi_REC_TYP , " +
                                       " fpi_CRD_LN , " +
                                       " fpi_CRD_FIID , " +
                                       " fpi_CRD_NUM , " +
                                       " fpi_MBR_NUM , " +
                                       " fpi_MER_LN , " +
                                       " fpi_MER_FIID , " +
                                       " fpi_MER_GRP , " +
                                       " fpi_MER_REGN , " +
                                       " fpi_MER_ID , " +
                                       " fpi_TERM_ID , " +
                                       " fpi_SHIFT_NUM , " +
                                       " fpi_BATCH_NUM , " +
                                       " fpi_TERM_LN , " +
                                       " fpi_TERM_FIID , " +
                                       " fpi_TERM_ID_1 , " +
                                       " fpi_TRAN , " +
                                       " fpi_TERM_ID_2 , " +
                                       " fpi_REC_FRMT , " +
                                       " fpi_MER_ID_1 , " +
                                       " fpi_CLERK_ID , " +
                                       " fpi_DATA_FLAG , " +
                                       " fpi_TYP , " +
                                       " fpi_RTE_STAT , " +
                                       " fpi_ORIGINATOR , " +
                                       " fpi_RESPONDER , " +
                                       " fpi_ISS_CDE , " +
                                       " fpi_ENTRY_TIM , " +
                                       " fpi_EXIT_TIM , " +
                                       " fpi_RE_ENTRY_TIM , " +
                                       " fpi_TRAN_DAT , " +
                                       " fpi_TRAN_TIM , " +
                                       " fpi_POST_DAT , " +
                                       " fpi_ACQ_ICHG_SETL_DAT , " +
                                       " fpi_ISS_ICHG_SETL_DAT , " +
                                       " fpi_SEQ_NUM , " +
                                       " fpi_TERM_NAME_LOC , " +
                                       " fpi_TERM_OWNER_NAME , " +
                                       " fpi_TERM_CITY , " +
                                       " fpi_TERM_ST , " +
                                       " fpi_TERM_CNTRY_CDE , " +
                                       " fpi_BRCH_ID , " +
                                       " fpi_USER_FLD2 , " +
                                       " fpi_TERM_TIM_OFST , " +
                                       " fpi_ACQ_INST_ID_NUM , " +
                                       " fpi_RCV_INST_ID_NUM , " +
                                       " fpi_TERM_TYP , " +
                                       " fpi_CLERK_ID_1 , " +
                                       " fpi_GRP , " +
                                       " fpi_USER_ID , " +
                                       " fpi_RETL_SIC_CDE , " +
                                       " fpi_ORIG , " +
                                       " fpi_DEST , " +
                                       " fpi_TC , " +
                                       " fpi_T , " +
                                       " fpi_AA , " +
                                       " fpi_C , " +
                                       " fpi_CRD_TYP , " +
                                       " fpi_ACCT , " +
                                       " fpi_RESP_CDE , " +
                                       " fpi_AMT_1 , " +
                                       " fpi_AMT_2 , " +
                                       " fpi_EXP_DAT , " +
                                       " fpi_TRACK2 , " +
                                       " fpi_PIN_OFST , " +
                                       " fpi_PRE_AUTH_SEQ_NUM , " +
                                       " fpi_INVOICE_NUM , " +
                                       " fpi_ORIG_INVOICE_NUM , " +
                                       " fpi_AUTHORIZER , " +
                                       " fpi_AUTH_IND , " +
                                       " fpi_SHIFT_NUM_1 , " +
                                       " fpi_BATCH_SEQ_NUM , " +
                                       " fpi_APPRV_CDE , " +
                                       " fpi_APPRV_CDE_LGTH , " +
                                       " fpi_ICHG_RESP , " +
                                       " fpi_PSEUDO_TERM_ID , " +
                                       " fpi_RFRL_PHONE , " +
                                       " fpi_DFT_CAPTURE_FLG , " +
                                       " fpi_SETL_FLAG , " +
                                       " fpi_RVRL_CDE , " +
                                       " fpi_REA_FOR_CHRGBCK , " +
                                       " fpi_NUM_OF_CHRGBCK , " +
                                       " fpi_PT_SRV_COND_CDE , " +
                                       " fpi_PT_SRV_ENTRY_MDE , " +
                                       " fpi_AUTH_IND2 , " +
                                       " fpi_ORIG_CRNCY_CDE , " +
                                       " fpi_AUTH_CRNCY_CDE , " +
                                       " fpi_AUTH_CONV_RATE , " +
                                       " fpi_SETL_CRNCY_CDE , " +
                                       " fpi_SETL_CONV_RATE , " +
                                       " fpi_CONV_DAT_TIM , " +
                                       " fpi_IMP_IND , " +
                                       " fpi_AVAIL_BAL , " +
                                       " fpi_LEDG_BAL , " +
                                       " fpi_AMT_ON_HOLD , " +
                                       " fpi_TTL_FLOAT , " +
                                       " fpi_CUR_FLOAT , " +
                                       " fpi_ADJ_SETL_IMPACT_FLG , " +
                                       " fpi_PBF1 , " +
                                       " fpi_PBF2 , " +
                                       " fpi_PBF3 , " +
                                       " fpi_PBF4 , " +
                                       " fpi_FRWD_INST_ID_NUM , " +
                                       " fpi_CRD_ACCPT_ID_NUM , " +
                                       " fpi_CRD_ISS_ID_NUM , " +
                                       " fpi_ORIG_MSG_TYP , " +
                                       " fpi_ORIG_TRAN_TIM , " +
                                       " fpi_ORIG_TRAN_DAT , " +
                                       " fpi_ORIG_SEQ_NUM , " +
                                       " fpi_ORIG_B24_POST_DAT , " +
                                       " fpi_EXCP_RSN_CDE , " +
                                       " fpi_OVRRDE_FLG , " +
                                       " fpi_ADDR , " +
                                       " fpi_ZIP_CDE , " +
                                       " fpi_ADDR_VRFY_STAT , " +
                                       " fpi_PIN_IND , " +
                                       " fpi_PIN_TRIES , " +
                                       " fpi_PRE_AUTH_TS_DAT , " +
                                       " fpi_PRE_AUTH_TS_TIM , " +
                                       " fpi_PRE_AUTH_HLDS_LVL , " +
                                       " fpi_USER_FLD5 , " +
                                       " fpi_LEN , " +
                                       " fpi_INFO )" +
                                       " VALUES ( " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                   pConn = mConnPool.getConnection();
                   PreparedStatement pStmt = pConn.prepareStatement(psInsSql);
                   while (!pbEndOfFile)
                        pcData = new char [HEADERSIZE];                    // Reading each Block Header
                        brPTLF.read (pcData, 0, HEADERSIZE);
                        piBlocksize = Integer.parseInt (new String (pcData));
                        piOffset = HEADERSIZE;
                        while (piOffset < piBlocksize)
                        {                      // Read the records upto end of block
                             pcData = new char [HEADERSIZE];               // Reading each Record Header
                             brPTLF.read (pcData, 0, HEADERSIZE);
                             piRecordsize = Integer.parseInt (new String (pcData));
                             piOffset += HEADERSIZE;
                             pcData = new char [piRecordsize - HEADERSIZE];     // Reading each Record Content
                             brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
                             psRecordContent = new String (pcData);
                             piOffset += piRecordsize - HEADERSIZE;
                             moLogFile.writeToLog(psRecordContent);
                             if (pbisFirstBlock)
                                  if (!psRecordContent.startsWith ("TH"))
                                       throw new GenException ("Invalid File Format, missing 'TH'");
                                  pcData = new char [HEADERSIZE];          // Reading next Record Header
                                  brPTLF.read (pcData, 0, HEADERSIZE);
                                  piRecordsize = Integer.parseInt (new String (pcData));
                                  piOffset += HEADERSIZE;
                                  pcData = new char [piRecordsize - HEADERSIZE];// Reading next Record Content (Must be FH)
                                  brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
                                  psRecordContent = new String (pcData);
                                  piOffset += piRecordsize - HEADERSIZE;
                                  if (!psRecordContent.startsWith ("FH"))
                                       throw new GenException ("File Header Not Found");
                                  pbisFirstBlock = false;
                             else if (psRecordContent.startsWith ("DR"))
                                  psRecordContent = psRecordContent.substring(2);
                        /*          if (psRecordContent.length() != 1820 ) // && psRecordContent.length() != 846)
                                       // insert in error table
                                       continue;
                                  if ( psRecordContent.substring(453-1, 455).equals ("000") || psRecordContent.substring(453-1, 455).equals ("001") )
                                       pStmt.setString (1, psRecordContent.substring(1-1,19));
                                       pStmt.setString (2, psRecordContent.substring(20-1,21));
                                       pStmt.setString (3, psRecordContent.substring(22-1,25));
                                       pStmt.setString (4, psRecordContent.substring(26-1,29));
                                       pStmt.setString (5, psRecordContent.substring(30-1,48));
                                       pStmt.setString (6, psRecordContent.substring(49-1,51));
                                       pStmt.setString (7, psRecordContent.substring(52-1,55));
                                       pStmt.setString (8, psRecordContent.substring(56-1,59));
                                       pStmt.setString (9, psRecordContent.substring(60-1,63));
                                       pStmt.setString (10, psRecordContent.substring(64-1,67));
                                       pStmt.setString (11, psRecordContent.substring(68-1,86));
                                       pStmt.setString (12, psRecordContent.substring(87-1,102));
                                       pStmt.setString (13, psRecordContent.substring(103-1,105));
                                       pStmt.setString (14, psRecordContent.substring(106-1,108));
                                       pStmt.setString (15, psRecordContent.substring(109-1,112));
                                       pStmt.setString (16, psRecordContent.substring(113-1,116));
                                       pStmt.setString (17, psRecordContent.substring(117-1,132));
                                       pStmt.setString (18, psRecordContent.substring(133-1,140));
                                       pStmt.setString (19, psRecordContent.substring(141-1,156));
                                       pStmt.setString (20, psRecordContent.substring(157-1,157));
                                       pStmt.setString (21, psRecordContent.substring(158-1,176));
                                       pStmt.setString (22, psRecordContent.substring(177-1,182));
                                       pStmt.setString (23, psRecordContent.substring(183-1,183));
                                       pStmt.setString (24, psRecordContent.substring(184-1,187));
                                       pStmt.setString (25, psRecordContent.substring(188-1,189));
                                       pStmt.setString (26, psRecordContent.substring(190-1,190));
                                       pStmt.setString (27, psRecordContent.substring(191-1,191));
                                       pStmt.setString (28, psRecordContent.substring(192-1,193));
                                       pStmt.setString (29, psRecordContent.substring(194-1,212));
                                       pStmt.setString (30, psRecordContent.substring(213-1,231));
                                       pStmt.setString (31, psRecordContent.substring(232-1,250));
                                       pStmt.setString (32, psRecordContent.substring(251-1,256));
                                       pStmt.setString (33, psRecordContent.substring(257-1,264));
                                       pStmt.setString (34, psRecordContent.substring(265-1,270));
                                       pStmt.setString (35, psRecordContent.substring(271-1,276));
                                       pStmt.setString (36, psRecordContent.substring(277-1,282));
                                       pStmt.setString (37, psRecordContent.substring(283-1,294));
                                       pStmt.setString (38, psRecordContent.substring(295-1,319));
                                       pStmt.setString (39, psRecordContent.substring(320-1,341));
                                       pStmt.setString (40, psRecordContent.substring(342-1,354));
                                       pStmt.setString (41, psRecordContent.substring(355-1,357));
                                       pStmt.setString (42, psRecordContent.substring(358-1,359));
                                       pStmt.setString (43, psRecordContent.substring(360-1,363));
                                       pStmt.setString (44, psRecordContent.substring(364-1,366));
                                       pStmt.setString (45, psRecordContent.substring(367-1,371));
                                       pStmt.setString (46, psRecordContent.substring(372-1,382));
                                       pStmt.setString (47, psRecordContent.substring(383-1,393));
                                       pStmt.setString (48, psRecordContent.substring(394-1,395));
                                       pStmt.setString (49, psRecordContent.substring(396-1,401));
                                       pStmt.setString (50, psRecordContent.substring(402-1,405));
                                       pStmt.setString (51, psRecordContent.substring(406-1,413));
                                       pStmt.setString (52, psRecordContent.substring(414-1,417));
                                       pStmt.setString (53, psRecordContent.substring(418-1,421));
                                       pStmt.setString (54, psRecordContent.substring(422-1,425));
                                       pStmt.setString (55, psRecordContent.substring(426-1,427));
                                       pStmt.setString (56, psRecordContent.substring(428-1,428));
                                       pStmt.setString (57, psRecordContent.substring(429-1,430));
                                       pStmt.setString (58, psRecordContent.substring(431-1,431));
                                       pStmt.setString (59, psRecordContent.substring(432-1,433));
                                       pStmt.setString (60, psRecordContent.substring(434-1,452));
                                       pStmt.setString (61, psRecordContent.substring(453-1,455));
                                       pStmt.setString (62, psRecordContent.substring(456-1,474));
                                       pStmt.setString (63, psRecordContent.substring(475-1,493));
                                       pStmt.setString (64, psRecordContent.substring(494-1,497));
                                       pStmt.setString (65, psRecordContent.substring(498-1,537));
                                       pStmt.setString (66, psRecordContent.substring(538-1,553));
                                       pStmt.setString (67, psRecordContent.substring(554-1,565));
                                       pStmt.setString (68, psRecordContent.substring(566-1,575));
                                       pStmt.setString (69, psRecordContent.substring(576-1,585));
                                       pStmt.setString (70, psRecordContent.substring(586-1,601));
                                       pStmt.setString (71, psRecordContent.substring(602-1,602));
                                       pStmt.setString (72, psRecordContent.substring(603-1,605));
                                       pStmt.setString (73, psRecordContent.substring(606-1,608));
                                       pStmt.setString (74, psRecordContent.substring(609-1,616));
                                       pStmt.setString (75, psRecordContent.substring(617-1,617));
                                       pStmt.setString (76, psRecordContent.substring(618-1,625));
                                       pStmt.setString (77, psRecordContent.substring(626-1,629));
                                       pStmt.setString (78, psRecordContent.substring(630-1,649));
                                       pStmt.setString (79, psRecordContent.substring(650-1,650));
                                       pStmt.setString (80, psRecordContent.substring(651-1,651));
                                       pStmt.setString (81, psRecordContent.substring(652-1,653));
                                       pStmt.setString (82, psRecordContent.substring(654-1,655));
                                       pStmt.setString (83, psRecordContent.substring(656-1,656));
                                       pStmt.setString (84, psRecordContent.substring(657-1,658));
                                       pStmt.setString (85, psRecordContent.substring(659-1,661));
                                       pStmt.setString (86, psRecordContent.substring(662-1,662));
                                       pStmt.setString (87, psRecordContent.substring(663-1,665));
                                       pStmt.setString (88, psRecordContent.substring(666-1,668));
                                       pStmt.setString (89, psRecordContent.substring(669-1,676));
                                       pStmt.setString (90, psRecordContent.substring(677-1,679));
                                       pStmt.setString (91, psRecordContent.substring(680-1,687));
                                       pStmt.setString (92, psRecordContent.substring(688-1,706));
                                       pStmt.setString (93, psRecordContent.substring(707-1,707));
                                       pStmt.setString (94, psRecordContent.substring(708-1,708));
                                       pStmt.setString (95, psRecordContent.substring(709-1,709));
                                       pStmt.setString (96, psRecordContent.substring(710-1,710));
                                       pStmt.setString (97, psRecordContent.substring(711-1,711));
                                       pStmt.setString (98, psRecordContent.substring(712-1,712));
                                       pStmt.setString (99, psRecordContent.substring(713-1,713));
                                       pStmt.setString (100, psRecordContent.substring(714-1,714));
                                       pStmt.setString (101, psRecordContent.substring(715-1,715));
                                       pStmt.setString (102, psRecordContent.substring(716-1,716));
                                       pStmt.setString (103, psRecordContent.substring(717-1,717));
                                       pStmt.setString (104, psRecordContent.substring(718-1,728));
                                       pStmt.setString (105, psRecordContent.substring(729-1,739));
                                       pStmt.setString (106, psRecordContent.substring(740-1,750));
                                       pStmt.setString (107, psRecordContent.substring(751-1,754));
                                       pStmt.setString (108, psRecordContent.substring(755-1,762));
                                       pStmt.setString (109, psRecordContent.substring(763-1,766));
                                       pStmt.setString (110, psRecordContent.substring(767-1,778));
                                       pStmt.setString (111, psRecordContent.substring(779-1,782));
                                       pStmt.setString (112, psRecordContent.substring(783-1,785));
                                       pStmt.setString (113, psRecordContent.substring(786-1,786));
                                       pStmt.setString (114, psRecordContent.substring(787-1,806));
                                       pStmt.setString (115, psRecordContent.substring(807-1,815));
                                       pStmt.setString (116, psRecordContent.substring(816-1,816));
                                       pStmt.setString (117, psRecordContent.substring(817-1,817));
                                       pStmt.setString (118, psRecordContent.substring(818-1,818));
                                       pStmt.setString (119, psRecordContent.substring(819-1,824));
                                       pStmt.setString (120, psRecordContent.substring(825-1,832));
                                       pStmt.setString (121, psRecordContent.substring(833-1,833));
                                       pStmt.setString (122, psRecordContent.substring(834-1,866));
                                       pStmt.setString (123, psRecordContent.substring(867-1,870));
                                       pStmt.setString (124, psRecordContent.substring(871-1,1070));
                                       if (pStmt.executeUpdate() != 1)
                                            throw new GenException ("Insertion failed");
                                            String psMsgType = psRecordContent.substring (184-1, 187);
                                            if (true)//updateTable (conn, pstmt, pstmt1, pstmt2, psRecordContent, out, bw))
                                                 if (psMsgType.equals ("0500") || psMsgType.equals ("0520"))
                                                           //piSettlementDR++;
                                                 if (psMsgType.equals ("0210"))
                                                           //piUpdatedDR++;
                                                 if (psMsgType.equals ("0220") || psMsgType.equals ("0320") || psMsgType.equals ("0420"))
                                                      //reversalDR++;
                                                 //validDR++;
                                  //totalDR++;
                             else if (psRecordContent.startsWith ("FT"))
                                  pcData = new char [HEADERSIZE];     // Reading next Record Header
                                  brPTLF.read (pcData, 0, HEADERSIZE);
                                  piRecordsize = Integer.parseInt (new String (pcData));
                                  piOffset += HEADERSIZE;
                                  pcData = new char [piRecordsize - HEADERSIZE];// Reading next Record Content (Must be TT)
                                  brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
                                  psRecordContent = new String (pcData);
                                  piOffset += piRecordsize - HEADERSIZE;
                                  if (!psRecordContent.startsWith ("TT"))
                                       throw new GenException ("Total Trailer not Found.");
                                  pbEndOfFile = true;
                        } // while (piOffset < piBlocksize)
                   } // while (!pbEndOfFile)
                   brPTLF.close();
                   fPTLF.close();
                   pStmt.close();
              catch (Exception e)
                   moLogFile.printStackTrace(e);
              finally
                   mConnPool.free(pConn);
         public static void main(String args[])
              try
                   PTLFProcessor test=new PTLFProcessor("c:\\test.txt");
                   test.PTLFGetData();
              catch (Exception e)
                   clsLogFile.printStackTrace(e);
    }Now is the code with normal Statements
    //package mps.mpsPTLF;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.Calendar;
    import java.util.Date;
    import gen.genCommon.genConnectionPool.*;
    import gen.genCommon.*;
    public class PTLFProcessor1
         private static clsLogFile moLogFile = new clsLogFile("");
         private gen.genCommon.genConnectionPool.SharedConnectionPool mConnPool = SharedConnectionPool.getInstance(2);
         FileReader fPTLF = null;
         BufferedReader brPTLF = null;
    //**************** Begin Constructor declaration ************************
    To intialize the class variables for new Fee
         public PTLFProcessor1(String pathPTLF) throws GenException
              try
                   fPTLF = new FileReader(pathPTLF);
                   brPTLF = new BufferedReader(fPTLF);
              catch (Exception e)
                   throw new GenException("Error Accessing file : " + pathPTLF + " - " + e.toString(),e );     
    //**************** End  Constructor declaration ************************
         public void PTLFGetData() throws GenException
              char pcData[];
              int HEADERSIZE = 6;
              boolean pbEndOfFile = false;
              boolean pbisFirstBlock = true;
              int piBlocksize = 0;
              int piOffset = 0;
              int piRecordsize = 0;
              String psRecordContent = "";
              Connection pConn = null;
              int cnt=0;
              try
                   String psInsSql=" INSERT INTO FILE_PTLF_IN ( " +
                                       " fpi_DAT_TIM , " +
                                       " fpi_REC_TYP , " +
                                       " fpi_CRD_LN , " +
                                       " fpi_CRD_FIID , " +
                                       " fpi_CRD_NUM , " +
                                       " fpi_MBR_NUM , " +
                                       " fpi_MER_LN , " +
                                       " fpi_MER_FIID , " +
                                       " fpi_MER_GRP , " +
                                       " fpi_MER_REGN , " +
                                       " fpi_MER_ID , " +
                                       " fpi_TERM_ID , " +
                                       " fpi_SHIFT_NUM , " +
                                       " fpi_BATCH_NUM , " +
                                       " fpi_TERM_LN , " +
                                       " fpi_TERM_FIID , " +
                                       " fpi_TERM_ID_1 , " +
                                       " fpi_TRAN , " +
                                       " fpi_TERM_ID_2 , " +
                                       " fpi_REC_FRMT , " +
                                       " fpi_MER_ID_1 , " +
                                       " fpi_CLERK_ID , " +
                                       " fpi_DATA_FLAG , " +
                                       " fpi_TYP , " +
                                       " fpi_RTE_STAT , " +
                                       " fpi_ORIGINATOR , " +
                                       " fpi_RESPONDER , " +
                                       " fpi_ISS_CDE , " +
                                       " fpi_ENTRY_TIM , " +
                                       " fpi_EXIT_TIM , " +
                                       " fpi_RE_ENTRY_TIM , " +
                                       " fpi_TRAN_DAT , " +
                                       " fpi_TRAN_TIM , " +
                                       " fpi_POST_DAT , " +
                                       " fpi_ACQ_ICHG_SETL_DAT , " +
                                       " fpi_ISS_ICHG_SETL_DAT , " +
                                       " fpi_SEQ_NUM , " +
                                       " fpi_TERM_NAME_LOC , " +
                                       " fpi_TERM_OWNER_NAME , " +
                                       " fpi_TERM_CITY , " +
                                       " fpi_TERM_ST , " +
                                       " fpi_TERM_CNTRY_CDE , " +
                                       " fpi_BRCH_ID , " +
                                       " fpi_USER_FLD2 , " +
                                       " fpi_TERM_TIM_OFST , " +
                                       " fpi_ACQ_INST_ID_NUM , " +
                                       " fpi_RCV_INST_ID_NUM , " +
                                       " fpi_TERM_TYP , " +
                                       " fpi_CLERK_ID_1 , " +
                                       " fpi_GRP , " +
                                       " fpi_USER_ID , " +
                                       " fpi_RETL_SIC_CDE , " +
                                       " fpi_ORIG , " +
                                       " fpi_DEST , " +
                                       " fpi_TC , " +
                                       " fpi_T , " +
                                       " fpi_AA , " +
                                       " fpi_C , " +
                                       " fpi_CRD_TYP , " +
                                       " fpi_ACCT , " +
                                       " fpi_RESP_CDE , " +
                                       " fpi_AMT_1 , " +
                                       " fpi_AMT_2 , " +
                                       " fpi_EXP_DAT , " +
                                       " fpi_TRACK2 , " +
                                       " fpi_PIN_OFST , " +
                                       " fpi_PRE_AUTH_SEQ_NUM , " +
                                       " fpi_INVOICE_NUM , " +
                                       " fpi_ORIG_INVOICE_NUM , " +
                                       " fpi_AUTHORIZER , " +
                                       " fpi_AUTH_IND , " +
                                       " fpi_SHIFT_NUM_1 , " +
                                       " fpi_BATCH_SEQ_NUM , " +
                                       " fpi_APPRV_CDE , " +
                                       " fpi_APPRV_CDE_LGTH , " +
                                       " fpi_ICHG_RESP , " +
                                       " fpi_PSEUDO_TERM_ID , " +
                                       " fpi_RFRL_PHONE , " +
                                       " fpi_DFT_CAPTURE_FLG , " +
                                       " fpi_SETL_FLAG , " +
                                       " fpi_RVRL_CDE , " +
                                       " fpi_REA_FOR_CHRGBCK , " +
                                       " fpi_NUM_OF_CHRGBCK , " +
                                       " fpi_PT_SRV_COND_CDE , " +
                                       " fpi_PT_SRV_ENTRY_MDE , " +
                                       " fpi_AUTH_IND2 , " +
                                       " fpi_ORIG_CRNCY_CDE , " +
                                       " fpi_AUTH_CRNCY_CDE , " +
                                       " fpi_AUTH_CONV_RATE , " +
                                       " fpi_SETL_CRNCY_CDE , " +
                                       " fpi_SETL_CONV_RATE , " +
                                       " fpi_CONV_DAT_TIM , " +
                                       " fpi_IMP_IND , " +
                                       " fpi_AVAIL_BAL , " +
                                       " fpi_LEDG_BAL , " +
                                       " fpi_AMT_ON_HOLD , " +
                                       " fpi_TTL_FLOAT , " +
                                       " fpi_CUR_FLOAT , " +
                                       " fpi_ADJ_SETL_IMPACT_FLG , " +
                                       " fpi_PBF1 , " +
                                       " fpi_PBF2 , " +
                                       " fpi_PBF3 , " +
                                       " fpi_PBF4 , " +
                                       " fpi_FRWD_INST_ID_NUM , " +
                                       " fpi_CRD_ACCPT_ID_NUM , " +
                                       " fpi_CRD_ISS_ID_NUM , " +
                                       " fpi_ORIG_MSG_TYP , " +
                                       " fpi_ORIG_TRAN_TIM , " +
                                       " fpi_ORIG_TRAN_DAT , " +
                                       " fpi_ORIG_SEQ_NUM , " +
                                       " fpi_ORIG_B24_POST_DAT , " +
                                       " fpi_EXCP_RSN_CDE , " +
                                       " fpi_OVRRDE_FLG , " +
                                       " fpi_ADDR , " +
                                       " fpi_ZIP_CDE , " +
                                       " fpi_ADDR_VRFY_STAT , " +
                                       " fpi_PIN_IND , " +
                                       " fpi_PIN_TRIES , " +
                                       " fpi_PRE_AUTH_TS_DAT , " +
                                       " fpi_PRE_AUTH_TS_TIM , " +
                                       " fpi_PRE_AUTH_HLDS_LVL , " +
                                       " fpi_USER_FLD5 , " +
                                       " fpi_LEN , " +
                                       " fpi_INFO )" +
                                       " VALUES ";
                                       ( " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                                       " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
                   pConn = mConnPool.getConnection();
                   Statement Stmt=pConn.createStatement();
                   while (!pbEndOfFile)
                        pcData = new char [HEADERSIZE];                    // Reading each Block Header
                        brPTLF.read (pcData, 0, HEADERSIZE);
                        piBlocksize = Integer.parseInt (new String (pcData));
                        piOffset = HEADERSIZE;
                        while (piOffset < piBlocksize)
                        {                      // Read the records upto end of block
                             pcData = new char [HEADERSIZE];               // Reading each Record Header
                             brPTLF.read (pcData, 0, HEADERSIZE);
                             piRecordsize = Integer.parseInt (new String (pcData));
                             piOffset += HEADERSIZE;
                             pcData = new char [piRecordsize - HEADERSIZE];     // Reading each Record Content
                             brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
                             psRecordContent = new String (pcData);
                             piOffset += piRecordsize - HEADERSIZE;
                             if (pbisFirstBlock)
                                  if (!psRecordContent.startsWith ("TH"))
                                       throw new GenException ("Invalid File Format, missing 'TH'");
                                  pcData = new char [HEADERSIZE];          // Reading next Record Header
                                  brPTLF.read (pcData, 0, HEADERSIZE);
                                  piRecordsize = Integer.parseInt (new String (pcData));
                                  piOffset += HEADERSIZE;
                                  pcData = new char [piRecordsize - HEADERSIZE];// Reading next Record Content (Must be FH)
                                  brPTLF.read (pcData, 0, piRecordsize - HEADERSIZE);
                                  psRecordContent = new String (pcData);
                                  piOffset += piRecordsize - HEADERSIZE;
                                  if (!psRecordContent.startsWith ("FH"))
                                       throw new GenException ("File Header Not Found");
                                  pbisFirstBlock = false;
                             else if (psRecordContent.startsWith ("DR"))
                                  psRecordContent = psRecordContent.substring(2);
                        /*          if (psRecordContent.length() != 1820 ) // && psRecordContent.length() != 846)
                                       // insert in error table
                                       continue;
                                  String psValues = null;
                                  if ( psRecordContent.substring(453-1, 455).equals ("000") || psRecordContent.substring(453-1, 455).equals ("001") )
                                       psValues = "('" +  psRecordContent.substring(1-1,19) + "','" +
                                                        psRecordContent.substring(20-1,21) + "','" +
                                                       psRecordContent.substring(22-1,25) + "','" +
                                                       psRecordContent.substring(26-1,29) + "','" +
                                                       psRecordContent.substring(30-1,48) + "','" +
                                                       psRecordContent.substring(49-1,51) + "','" +
                                                       psRecordContent.substring(52-1,55) + "','" +
                                                       psRecordContent.substring(56-1,59) + "','" +
                                                       psRecordContent.substring(60-1,63) + "','" +
                                                       psRecordContent.substring(64-1,67) + "','" +
                                                       psRecordContent.substring(68-1,86) + "','" +
                                                       psRecordContent.substring(87-1,102) + "','" +
                                                       psRecordContent.substring(103-1,105) + "','" +
                                                       psRecordContent.substring(106-1,108) + "','" +
                                                       psRecordContent.substring(109-1,112) + "','" +
                                                       psRecordContent.substring(113-1,116) + "','" +
                                                       psRecordContent.substring(117-1,132) + "','" +
                                                       psRecordContent.substring(133-1,140) + "','" +
                                                       psRecordContent.substring(141-1,156) + "','" +
                                                       psRecordContent.substring(157-1,157) + "','" +
                                                       psRecordContent.substring(158-1,176) + "','" +
                                                       psRecordContent.substring(177-1,182) + "','" +
                                                       psRecordContent.substring(183-1,183) + "','" +
                                                       psRecordContent.substring(184-1,187) + "','" +
                                                       psRecordContent.substring(188-1,189) + "','" +
                                                       psRecordContent.substring(190-1,190) + "','" +
                                                       psRecordContent.substring(191-1,191) + "','" +
                                                       psRecordContent.substring(192-1,193) + "','" +
                                                       psRecordContent.substring(194-1,212) + "','" +
                                                       psRecordContent.substring(213-1,231) + "','" +
                                                       psRecordContent.substring(232-1,250) + "','" +
                                                       psRecordContent.substring(251-1,256) + "','" +
                                                       psRecordContent.substring(257-1,264) + "','" +
                                                       psRecordContent.substring(265-1,270) + "','" +
                                                       psRecordContent.substring(271-1,276) + "','" +
                                                       psRecordContent.substring(277-1,282) + "','" +
                                                       psRecordContent.substring(283-1,294) + "','" +
                                                       psRecordContent.substring(295-1,319) + "','" +
                                                       psRecordContent.substring(320-1,341) + "','" +
                                                       psRecordContent.substring(342-1,354) + "','" +
                                                       psRecordContent.substring(355-1,357) + "','" +
                                                       psRecordContent.substring(358-1,359) + "','" +
                                                       psRecordContent.substring(360-1,363) + "','" +
       

    You posted this question in several other forums. Please don't do that.

  • ? 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.

  • How to retrieve a prepared statement from prepared statement cache?

    Hi All,
    I have created the connection pool during application server startup. The connection pool are getting created successfully. I have also created the prepared statements and stored as part of each connection in the connection pool.
    can anyone please tell me on how do I retrieve a prepared statement from prepared statement cache from a connection object.
    Any pointers to info source will be REALLY appreciated.
    Many Thanks in Advance,
    C R Baradwaj

    Raghuram Bharatwaj C wrote:
    Hi Joe,
    I have created a connection poool in my startup class and created the
    neccessary prepared statements for a each connection. I have 10 prepared
    statements to be created for each connection. I have created all the 10 prepared statements using the loop as mentioned below
    String [] epc_stmts;
    private java.sql.PreparedStatement[] _pstmts;
    if (epc_stmts!= null)
                   _pstmts = new PreparedStatement [len = epc_stmts.length];
                   for (i=0; i<len; i++)
                        _pstmts[i] = db.prepareStatement (epcstmts);
    I have closed the connection after the prepared statements are created.
    Now, How do i access a prepared statement from the connection object.
    Nothing. Are you talking about a WebLogic pool? If so, then therafter,
    whenever your application gets a pool connection, when it calls
    prepareStatement() with the same SQL as you prepared those statements,
    it will get a cached statement. Your array is unnecessary.
    Joe
    >
    Many Thanks in Advance,
    C R Baradwaj

  • In the privacy policy, it states that percentages and durations of books read are being collected to ensure that publishers can have a metered price model, prices depending on how the book was read. Give me an example of a company with such a price model?

    In your privacy policy, you state that the percentages and durations of books read are being collected to ensure that publishers can choose a metered price model. Prices which depends on the duration for which the book was read.
    Give me an example of a company with such a price model? Are the information being collected even where the companies have not asked for the information, even when the metered price models are not being used?
    Here is an extract från the privacy policy:
    What information does Adobe Digital Editions collect and how is it used?
    The following information may be collected when an eBook with DRM is opened in Adobe Digital Editions software. If an eBook does not have any DRM associated with it, then no information is collected.
    User GUID: The User GUID is a unique value assigned in place of your User ID and is used to authenticate you.
    Device GUID: The Device GUID is a unique value generated to identify your device. It is used to ensure that the eBook may be viewed on your device and that the number of devices permitted by the license is not exceeded.
    Certified App ID: This ID represents the application that is being used to view the eBook, in this case Adobe Digital Editions. It is necessary to ensure that only a certified application may display an eBook. This helps to minimize piracy and theft of eBooks.
    Device IP (Internet Protocol): This identifies the country you are located in when you purchase an eBook.  It is used by eBook providers for the enablement of localized pricing models. Only the country identifier of the Device IP is stored.
    Duration for Which the Book was Read: This information may be collected to facilitate limited or metered pricing models entered into between eBook providers, such as publishers and distributors. These models are based on how long a reader has read an eBook. For example, you may borrow an eBook for a period of 30 days. While some publishers and distributors may charge libraries and resellers for 30 days from the date of the download, others may follow a metered pricing model and charge them for the actual time you read the eBook.
    Percentage of the eBook Read: The percentage of the eBook read may be collected to allow eBook providers such as publishers to implement subscription pricing models where they charge based on the percentage of the eBook read.
    Information provided by eBook providers relating to the eBook you have purchased: The following information is provided by the eBook provider to enable the delivery of the eBook to your device:Date of eBook purchase/download
    Distributor ID and Adobe Content Server Operator URL
    Metadata of the eBook, such as title, author, language, publisher list price, ISBN number
    How is the information transmitted?
    The data is sent periodically to Adobe via a secure transmission using HTTPS.
    How is the information used?
    Adobe uses the information collected about the eBook you have opened in Adobe Digital Editions software to ensure it is being viewed in accordance with the type of DRM license that accompanies that eBook. The type of license is determined by the eBook provider. For more information on how each piece of data is used, please see above.

    In your privacy policy, you state that the percentages and durations of books read are being collected to ensure that publishers can choose a metered price model. Prices which depends on the duration for which the book was read.
    Give me an example of a company with such a price model? Are the information being collected even where the companies have not asked for the information, even when the metered price models are not being used?
    Here is an extract från the privacy policy:
    What information does Adobe Digital Editions collect and how is it used?
    The following information may be collected when an eBook with DRM is opened in Adobe Digital Editions software. If an eBook does not have any DRM associated with it, then no information is collected.
    User GUID: The User GUID is a unique value assigned in place of your User ID and is used to authenticate you.
    Device GUID: The Device GUID is a unique value generated to identify your device. It is used to ensure that the eBook may be viewed on your device and that the number of devices permitted by the license is not exceeded.
    Certified App ID: This ID represents the application that is being used to view the eBook, in this case Adobe Digital Editions. It is necessary to ensure that only a certified application may display an eBook. This helps to minimize piracy and theft of eBooks.
    Device IP (Internet Protocol): This identifies the country you are located in when you purchase an eBook.  It is used by eBook providers for the enablement of localized pricing models. Only the country identifier of the Device IP is stored.
    Duration for Which the Book was Read: This information may be collected to facilitate limited or metered pricing models entered into between eBook providers, such as publishers and distributors. These models are based on how long a reader has read an eBook. For example, you may borrow an eBook for a period of 30 days. While some publishers and distributors may charge libraries and resellers for 30 days from the date of the download, others may follow a metered pricing model and charge them for the actual time you read the eBook.
    Percentage of the eBook Read: The percentage of the eBook read may be collected to allow eBook providers such as publishers to implement subscription pricing models where they charge based on the percentage of the eBook read.
    Information provided by eBook providers relating to the eBook you have purchased: The following information is provided by the eBook provider to enable the delivery of the eBook to your device:Date of eBook purchase/download
    Distributor ID and Adobe Content Server Operator URL
    Metadata of the eBook, such as title, author, language, publisher list price, ISBN number
    How is the information transmitted?
    The data is sent periodically to Adobe via a secure transmission using HTTPS.
    How is the information used?
    Adobe uses the information collected about the eBook you have opened in Adobe Digital Editions software to ensure it is being viewed in accordance with the type of DRM license that accompanies that eBook. The type of license is determined by the eBook provider. For more information on how each piece of data is used, please see above.

  • HT4059 Being new to iBook publishing I need to know if stats are available to determine how many times my iBook has been downloaded. Can anyone help please? Mr Ignorant

    Being new to iBook publishing I need to know if stats are available to determine how many times my iBook has been downloaded. Can anyone help please? I need to persuade someone that this really is worthwhile. Mr Ignorant.

    The only people who can possibly assist you with this is Apple Customer Relations, call your local Apple contact number and ask for Customer Relations then explain your situation clearly and politely (be firm but don't rant).
    You might want to investiage what the local laws are regarding defective goods and 'fit for use' definitions on warranties etc. Consumer Protection can be a useful tool to use or bargain with if needed ...

  • Deployments are in Active state on Cluster but in Prepared state on server

    Hi,
    We initially deployed our application (Oracle Identity Manager 11gR2) on standalone managed server and then convert it into cluster using wlst commands.
    readDomain('/app/oracle/Middleware_OAM/user_projects/domains/oim_domain')
    setDistDestType('JRFWSAsyncJmsModule', 'UDD')
    setDistDestType('OIMJMSModule', 'UDD')
    create('oim_cluster','Cluster')
    assign('Server','oim_server1','Cluster','oim_cluster')
    updateDomain()
    The cluster is created fine and we can start the application successfully and access it. However the problem is that all the deployments are in 'Active' state only under Cluster but in prepared state under the server oim_server1 (though application access working on managed server port). Please advise where we are missing and what could be the wrong?
    Thanks

    Hi,
    1. What if you are trying to access the application page, does it come up ?
    2. Use the below wlst command to get the actual state of the deployed application:
    The deploy command returns a WLSTProgress object that you can access to check the status of the command. The WLSTProgress object is captured in a user-defined variable, in this case, progress.
    wls:/mydomain/serverConfig/Servers> progress= deploy(appName='businessApp',path='c:/myapps/business',createplan='true')
    The previous example stores the WLSTProgress object returned in a user-defined variable, in this case, progress. You can then use the progress variable to print the status of the deploy command. For example:
    wls:/mydomain/serverConfig/Servers> progress.printStatus()
    Current Status of your Deployment:
    Deployment command type: deploy
    Deployment State       : completed
    Deployment Message     : null
    wls:/mydomain/serverConfig/Servers>
    3. Restart all the servers, instances, related DB and check if it helps.
    Thanks,
    Sharmela

  • Problem with Prepared Statement & MS Access

    Hi
    I have tried to find some info about this but can't see anything specific to what I think the problem may be. Hopefully someone can point me in the right direction.I am trying to get information out of an MS Access database using a Prepared Statement but I am getting strange results.
    When I run the query in the database it gives me the correct totals (�51) for 4 records. When I run the Prepared Statement ,I get 81. Has it got anything to do with the data type I am using( sorry if this is a really basic question). here is my code- the connection etc is elsewhere.
    private void getReportMoneyTotal() throws SQLException
              Calendar todayTotal =Calendar.getInstance() ;
               SimpleDateFormat reportDateFormat = new SimpleDateFormat("dd MM yyyy");
              PreparedStatement preparedT =context.getConnection().prepareStatement(
                   "SELECT Sum(tblSession.Fee) AS Total, Count(tblBooking.BookingID) AS CountOfBookingID FROM tblSession INNER JOIN "+
                   "(tblBooking INNER JOIN tblCustomer_Booking ON tblBooking.BookingID = tblCustomer_Booking.BookingID) ON tblSession.SessionID = tblBooking.SessionID "+
                   "WHERE (((tblBooking.EventDate)>DateAdd('m',-1,#"+reportDateFormat.format(todayTotal.getTime())+"#)) AND ((tblSession.Session)='Morning' Or (tblSession.Session)='Evening')) OR (((tblSession.Session)='Afternoon') AND ((tblBooking.Extension)=Yes))"
              ResultSet resultTotal =preparedT.executeQuery();
              resultTotal.next();
              Double total =resultTotal.getDouble("Total");
              Locale locale = new Locale("GBP");
            NumberFormat gbpFormat = NumberFormat.getCurrencyInstance(locale);
              System.out.println(gbpFormat.format(total));
              preparedT.close();
         }I do realise that my code probably isn't very elegant but I'm only learning!

    Hi Matt--
    I am not clear if you are saving the url with the # # around
    the text or if
    the
    data already contains the # marks.
    When you insert a link, you want to make sure you insert is
    insert into table ( link1) values ( <cfqueryparam
    cfsqltype="cf_sql_varchar"
    value='#linkvaluehere#'> )
    remember to
    1) enclose your data's value inside quotes (some databases
    are picky about
    single v. double quotes).
    2) if it IS in quotes, swap doubles for singles and see if
    that helps.
    3) make sure your data being saved is NOT double hashed like
    '##linkvalueher##'. Double ##'s tell
    Coldfusion not to treat it as a variable.
    hope his helps,
    tami
    "Mattastic" <[email protected]> wrote in
    message
    news:f9c7h0$8ub$[email protected]..
    | Hi Folks,
    |
    | I'm storing a link in a nvarchar field in SQL server,
    www.foo.co.uk, it
    looks
    | and works fine in SQL server. Problem occurs when I setup
    an ADP in Access
    and
    | insert links. Certain links have a hash symbol around them.
    so
    |
    http://www.foo.co.uk, would be #
    http://www.foo.co.uk# which is
    causing
    problems.
    |
    | Can anyone tell me why this is happening? and how to stop
    it?
    |
    | Thankyou
    |

  • Beginner question about prepared statements...PLEASE help! :-)

    First let me say thanks for the assistance. This is probably really easy to do, but I'm new to JSP and can't seem to figure it out.
    I want to dynamically populate a table that shows whether a particular person has an appointment at a given date and time with a user. To do this, I want to query the MySQL database for the lastname of the person with the appointment that occurs with the user at the year, month, date, and time, in question.
    THE CODE BELOW DOESN'T WORK (obviously) BUT SOMEWHAT ILLUSTRATES WHAT I'M TRYING TO ACCOMPLISH:
    <%
    Driver DriverTestRecordSet = (Driver)Class.forName(MM_website_DRIVER).newInstance();
    Connection ConnTestRecordSet = DriverManager.getConnection(MM_website_STRING,MM_website_USERNAME,MM_website_PASSWORD);
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='<%=(((Recordset1_data = Recordset1.getObject(user_id))==null || Recordset1.wasNull())?"":Recordset1_data)%>' AND year='<%= yy %>' AND month='<%= months[mm] %>' AND date='<%= dates[dd] %>' AND appttime='16:15:00'");
    ResultSet TestRecordSet = StatementTestRecordSet.executeQuery();
    boolean TestRecordSet_isEmpty = !TestRecordSet.next();
    boolean TestRecordSet_hasData = !TestRecordSet_isEmpty;
    Object TestRecordSet_data;
    int TestRecordSet_numRows = 0;
    %>
    The real problem comes in the prepared statement portion. If I build the prepared statement with static values like below, EVERYTHING WORKS GREAT:
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id='1' AND year='2002' AND month='October' AND date='31' AND appttime='16:15:00'");
    But when I try to use dynamic values, everything falls apart. It's not that the values aren't defined, I use the user_id, year <%= yy %>, month <%= months[mm] %>, etc. elsewhere on the page with no problems. It's just that I can't figure out how to use these dynamic values within the prepared statement.
    Thanks for reading this far and thanks in advance for the help!!!!

    Hi PhineasGage
    You are little bit wrong in your
    your preparedStatement.
    Expression tag within scriptlet tag is invalid.
    Whenever you are appending the statement with
    expression tag, append it with "+" and remove
    expression tag.
    Hopefully it will work
    ThanksThanks for the response!
    I know that the expression tag within scriptlet tag is invalid. I just need a workaround for what I want to do.
    I'm unclear what you mean by "Whenever you are appending the statement with expression tag, append it with a "+" and remove expression tag".
    Could you give an example?
    In the meantime, I've been trying to digest the docs on prepared statements and have changed the code to look like:
    PreparedStatement StatementTestRecordSet = ConnTestRecordSet.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id= ? AND year= ? AND month= ? AND date= ? AND appttime='13:15:00'");
    StatementTestRecordSet.setInt(1,1);
    StatementTestRecordSet.setInt(2,2002);
    StatementTestRecordSet.setString(3,"October");
    StatementTestRecordSet.setInt(4,31);
    Again, WITH THE STATIC VALUES, THIS WORKS FINE...but when I try to use expressions or variables like below, things don't work:
    StatementTestRecordSet.setInt(2,<%= yy %>);
    Obviously, I'm doing something wrong, but there has to be a way to use variables within the prepared statement.
    ALSO, the values are being passed to this page via URL in the form:
    samplepage?user_id=1&year=2002&month=October&date=31
    Based upon this information, is there another way (outside of stored procedures in the db) to do what I want to do? I'm open to ideas.

  • ODBC 'NOW' function in prepared statement?

    I'm writing a class that logs data to a ODBC datasource (using JDK 1.5). I've set up a link to a Microsoft Access database to test against.
    I've written a couple of prepared statements, that all work well. Now, I'm trying to add a timestamp in a column, and things go wrong. I'm not seeing why. Can anyone point out my mistake?
    first, I'm checking if the ODBC datasource has the 'NOW' function available:
    if (!this.con.getMetaData().getTimeDateFunctions().contains(",NOW,") )
      System.err.println("ODBC datasource does not provide the 'NOW' function. Timestamps will not be logged!");
      this.pstmInsertItem =
        con.prepareStatement("INSERT INTO myTable (id, ip, endUser) VALUES (?, ?, ?);
    else
      this.pstmInsertItem =
        con.prepareStatement("INSERT INTO myTable (id, timestamp, ip, endUser) VALUES (?, NOW(), ?, ?);
    }Sadly, once filled out and executed, a SQLException is thrown. getMessage() tells me: "[Microsoft] [ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement."
    A few things that are odd:
    If I remove the 'timestamp,' and 'NOW(),' from the latter prepared statement (thus making it similar to the first query), the query executes fine.
    If I execute the query in MS Access directly, timestamps are logged perfectly (I have to leave out the () after NOW though).
    The statement below does execute perfectly, even though it makes use of another ODBC function: "SELECT MAX(id) FROM myTable WHERE " (...and so on).
    I've tried several variations of the NOW function (NOW, now, NOW() etc) but none of them seem to work. Can someone help me out here?

    Well, one reason to use database-supplied timestamps rather than client-supplied timestamps is that you often have only one database host but may have multiple clients whose system times aren't effectively synchronized. In other words, since a DB date function like SYSDATE can change the source of the time from client to server, it's NOT an exact functional equivalent to the java.sqlTimestamp class. This can be especially true with Swing apps; you don't exactly want an important date to have the client-side date when the user has (accidentally) set the system date ahead 2 months when seeing what day of the week Christmas falls on this year.
    I don't think this reasoning applies to MS access (I'm guessing that the client time is actually used by NOW() in Access - how could it not given the architecture?), but there are lots of other good reasons for being non-portable, not least being when you really truly know you're never ever going to port the code to another DB.
    Portability is just another tool in the toolbox; a good developer uses the right tools for the job and knows when portability is being broken. Newbies of course don't know the value of portability and don't know when they're breaking it.
    And our poor original poster has already pummeled himself about the reserved word...

  • Oracle Cached Prepared Statement

    We recently upgraded from WL 8.1 SP3 to WL 9.2 and in the process updated the JDBC Driver for Oracle from 10.2.0.1 to 10.2.0.2. After we went live we started seeing issue in one table. The table contains some special character which is not suppose to be there.
    Here is the code & table details
    PreparedStatement pstmt = cn.prepareStatement("INSERT INTO INFO_TABLE(user_name,user_status) values (?,?)");
    pstmt.setString(1,requestObject.getUserName());
    if(requestObject.isValidUser)
    pstmt.setInt(2,requestObject.getStatus());
    }else
    pstmt.setNull(2,Types.VARCHAR);
    cn.commit();
    Table description:
    USER_NAME VARCHAR2(60);
    USER_STATUS VARCHAR2(5);
    - The USER_STATUS columns valid values are 0-4 or NULL.
    The problem is on certain occasions the valid user value in the table is some special character. I got the ascii value of this character as 128. We don't know yet whether setting int value and varchar (null) value on two different flow (but cached prepared statement) is the issue.
    We can fix the code to use uniform data type but we need to be sure this is what causing the problem. Further when I read the docs http://e-docs.bea.com/wls/docs90/jdbc_admin/jdbc_datasources.html
    I can associate the problem I face with this pointer however as I said, we need some sort of confirmation to make this change in the production code.
    Here is what I am specifically looking for
    1. Is there a way to confirm this problem?
    2. Can we log the prepared statement being executed and the binded value being sent to the Oracle DB?
    I suspect the VARCHAR null type is being casted to int value 128.
    Would really appreciate any pointers on this.
    Thanks

    Purushothaman Thambu wrote:
    We recently upgraded from WL 8.1 SP3 to WL 9.2 and in the process updated the JDBC Driver for Oracle from 10.2.0.1 to 10.2.0.2. After we went live we started seeing issue in one table. The table contains some special character which is not suppose to be there.
    Here is the code & table details
    PreparedStatement pstmt = cn.prepareStatement("INSERT INTO INFO_TABLE(user_name,user_status) values (?,?)");
    pstmt.setString(1,requestObject.getUserName());
    if(requestObject.isValidUser)
    pstmt.setInt(2,requestObject.getStatus());
    }else
    pstmt.setNull(2,Types.VARCHAR);
    cn.commit();
    Table description:
    USER_NAME VARCHAR2(60);
    USER_STATUS VARCHAR2(5);
    - The USER_STATUS columns valid values are 0-4 or NULL.
    The problem is on certain occasions the valid user value in the table is some special character. I got the ascii value of this character as 128. We don't know yet whether setting int value and varchar (null) value on two different flow (but cached prepared statement) is the issue.
    We can fix the code to use uniform data type but we need to be sure this is what causing the problem. Further when I read the docs http://e-docs.bea.com/wls/docs90/jdbc_admin/jdbc_datasources.html
    I can associate the problem I face with this pointer however as I said, we need some sort of confirmation to make this change in the production code.
    Here is what I am specifically looking for
    1. Is there a way to confirm this problem?
    2. Can we log the prepared statement being executed and the binded value being sent to the Oracle DB?
    I suspect the VARCHAR null type is being casted to int value 128.
    Would really appreciate any pointers on this.
    ThanksHi. I don't think there's any issue with WebLogic here, but the code you show
    might confuse some drivers. I highly recommend using setString for all
    varchar/char/varchar2 columns, not setInt(). If requestObject.getStatus()
    has to return an int, try this:
    if(requestObject.isValidUser)
    pstmt.setString(2, (""+ requestObject.getStatus()) );
    Joe

  • Prepared statement cache & Oracle

    Hi -
    Does Weblogic's prepared statement caching only work when using their
    type-2 Oracle driver? Are there any documents about using this
    Weblogic feature? I have only found small references in the Weblogic
    documentation so far -- nothing with much detail.
    Thanks for any help,
    - Mark

    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]..
    >
    >
    Mark Cassidy wrote:
    Hi -
    Does Weblogic's prepared statement caching only work when using their
    type-2 Oracle driver?No. It is generic to JDBC. Any JDBC driver should allow re-use ofPreparedStatements,
    and our pool will cache for any driver.
    Are there any documents about using this
    Weblogic feature? I have only found small references in the Weblogic
    documentation so far -- nothing with much detail.You are correct that there is too little documentation at this time.
    Thanks for any help,
    - Mark
    Thanks Joe!
    Do you know if each connection's cache is FIFO? Or do you use
    least-recently-used algorithm?
    I found one comment you made regarding XA pools. That means that if we are
    doing 2-phase commit processing that some of these benefits could erode? I
    didn't understand why. If we assume that the connections in a given pool
    after a time get a good sampling of popular prepared statements, would their
    being XA or not matter? Maybe I missed your point entirely.
    - Mark

  • 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.

  • Help changing to prepared statements for mysqli

    I am trying to change previously working php pages from mysql to mysqli using prepared statements.
    I am having problems with an error message.
    Basically the page I have just changed produces a set of database results depending on list menu and check box criteria from user input. I run 2 queries, one to find the total number of records, and the other to retrieve the required subset for pagination. All works fine. However if there are no actual results found from the requested input my php script then uses an includes file which basically runs the same 2 queries but with the user criteria narrowed down so that similar options are presented to the user. This is where my problem lies, for some unknown to me reason the second set of queries is producing no results and an error:
    'Attempt to read a row while there is no result set associated with the statement'
    If I run the second set of queries without running the first set then the second set works fine so I know that it is not the statements themselves but something in my new code. How can the first set of queries be affecting the results of the second set?
    Here is the code below which produces the first 2 queries that work, and below it the same code for the second 2 queries (which is from an 'Includes' file and is the same code exactly except the EXPECTED parameters $expected have been narrowed down in the expected array and list of params for binding).
    //list of possible field input by user
    $expected = array('location'   => 'text',
                      'type' => 'text',
                      'beds' => 'text',
                      'price' => 'text',
    'nbuild'     => 'int',
    'resale'     => 'int',
    'coastal'    => 'int',
    'seaview'    => 'int',
    'rural'      => 'int',
    'golf'       => 'int',
    'ppool'      => 'int',
    'comp'       => 'int',                            
    'garden'     => 'int',
    'terrace'    => 'int',
    'aircon'     => 'int',
    'heating'    => 'int',
    'garage'     => 'int',
    'telephone'  => 'int',
    'furnished'  => 'int',
    'internet'   => 'int',
    'dpaid'      => 'int',
    'propid'     => 'text');
    define('SHOWMAX', 10);
    // prepare SQL to get total records
    $getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $getTotal .= ' AND ';
          } else {
            $getTotal .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $getTotal .= "`$var` LIKE ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $getTotal .= "`$var` $operator ? ";
              break;
            default:
            $getTotal .= "`$var` = ? ";
    $getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($getTotal)) {
    $params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['nbuild'], $_GET['resale'], $_GET['coastal'], $_GET['seaview'], $_GET['rural'], $_GET['golf'], $_GET['ppool'], $_GET['comp'], $_GET['garden'], $_GET['terrace'],
    $_GET['aircon'], $_GET['heating'], $_GET['garage'], $_GET['telephone'], $_GET['furnished'], $_GET['internet'], $_GET['dpaid'], $_GET['propid']);
    $params = array_filter($params);
    $params = array_values($params);
    if (!empty($params)) {
                $types = '';
                foreach($params as $param) {
                    // set param type
                    if (is_string($param)) {
                        $types .= 's';  // strings
                    } else if (is_int($param)) {
                        $types .= 'i';  // integer
                    } else if (is_float($param)) {
                        $types .= 'd';  // double
                    } else {
                        $types .= 'b';  // default: blob and unknown types
                $bind_names[] = $types;
                for ($i=0; $i<count($params);$i++) {
                    $bind_name = 'bind' . $i;      
                    $$bind_name = $params[$i];     
    $bind_names[] = &$$bind_name;  
    call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($total);
    $stmt->fetch();
    // sort paging
    $totalRecords = $total;
    $stmt->free_result();
    $stmt->close();
    // check that there is at least 1 result and if there is do the second part of the search
    // if there is no result then I skip this second bit of code
    if($totalRecords > '0') {
    // check current page
    if (isset($_GET['curPage'])) {
    $curPage = $_GET['curPage'];
    } else {
    $curPage = 0;
    // calculate the start row of the subset
    $startRow = $curPage * SHOWMAX;        
    $sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $sql .= ' AND ';
          } else {
            $sql .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $sql .= "`$var` LIKE  ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $sql .= "`$var` $operator ? ";
              break;
            default:
            $sql .= "`$var` = ? ";
    $sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($sql)) {
    $nextparams = $params;
    if (!empty($nextparams)) {
                $nexttypes = '';
    foreach($nextparams as $nextparam) {
                    // set param type
                    if (is_string($nextparam)) {
    $nexttypes .= 's';  // strings
                    } else if (is_int($nextparam)) {
    $nexttypes .= 'i';  // integer
                    } else if (is_float($nextparam)) {
    $nexttypes .= 'd';  // double
                    } else {
    $nexttypes .= 'b';  // default: blob and unknown types
                $newbind_names[] = $nexttypes;
                for ($i=0; $i<count($nextparams);$i++) {
    $newbind_name = 'bind' . $i;      
    $$newbind_name = $nextparams[$i];
    $newbind_names[] = &$$newbind_name;
    call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
    $numRows = $stmt->num_rows;
    If a result was found in the part that checks the numbers of records then the second query is run and displayed using : while ($stmt->fetch()) { ...... to display the results and then I use $stmt->free_result();
    $stmt->close();
    All fine no problems.
    If the first query did not find a result then the second query is skipped and instead the script then uses a php includes file with exactly the same script as above except the expected params are narrowed as below: THIS IS WHEN I GET NO RESULTS – when I do expect to get a result) AND AN ERROR OF :
    Attempt to read a row while there is no result set associated with the statement.
    Yet if I run the includes file and skip the whole of the above code the code in the includes file find the result no problem. Anyway code below:
    $expected = array('location'   => 'text',
                      'type' => 'text',
                      'beds' => 'text',
                      'price' => 'text',
    'dpaid'      => 'int',
    'propid'     => 'text');
    define('SHOWMAX', 10);
    // prepare SQL to get total records
    $getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $getTotal .= ' AND ';
          } else {
            $getTotal .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $getTotal .= "`$var` LIKE ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $getTotal .= "`$var` $operator ? ";
              break;
            default:
            $getTotal .= "`$var` = ? ";
    $getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($getTotal)) {
    $params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['dpaid'], $_GET['propid']);
    $params = array_filter($params);
    $params = array_values($params);
    if (!empty($params)) {
                $types = '';
                foreach($params as $param) {
                    // set param type
                    if (is_string($param)) {
                        $types .= 's';  // strings
                    } else if (is_int($param)) {
                        $types .= 'i';  // integer
                    } else if (is_float($param)) {
                        $types .= 'd';  // double
                    } else {
                        $types .= 'b';  // default: blob and unknown types
                $bind_names[] = $types;
                for ($i=0; $i<count($params);$i++) {
                    $bind_name = 'bind' . $i;      
                    $$bind_name = $params[$i];     
    $bind_names[] = &$$bind_name;  
    call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($total);
    $stmt->fetch();
    // sort paging
    $totalRecords2 = $total;
    echo $stmt->error;
    $stmt->free_result();
    $stmt->close();
    // there is a result get the subset
    if($totalRecords2 > '0') {
    // check current page
    if (isset($_GET['curPage'])) {
    $curPage = $_GET['curPage'];
    } else {
    $curPage = 0;
    // calculate the start row of the subset
    $startRow = $curPage * SHOWMAX;        
    $sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $sql .= ' AND ';
          } else {
            $sql .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $sql .= "`$var` LIKE  ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $sql .= "`$var` $operator ? ";
              break;
            default:
            $sql .= "`$var` = ? ";
    $sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($sql)) {
    $nextparams = $params;
    if (!empty($nextparams)) {
                $nexttypes = '';
    foreach($nextparams as $nextparam) {
                    // set param type
                    if (is_string($nextparam)) {
    $nexttypes .= 's';  // strings
                    } else if (is_int($nextparam)) {
    $nexttypes .= 'i';  // integer
                    } else if (is_float($nextparam)) {
    $nexttypes .= 'd';  // double
                    } else {
    $nexttypes .= 'b';  // default: blob and unknown types
                $newbind_names[] = $nexttypes;
                for ($i=0; $i<count($nextparams);$i++) {
    $newbind_name = 'bind' . $i;      
    $$newbind_name = $nextparams[$i];
    $newbind_names[] = &$$newbind_name;
    call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
    $numRows = $stmt->num_rows;
    Again here I would then display the results before closing and freeing the stmt or display a message to say there were no results found from the criteria. But instead I get the error message and echoing the value of $totalRecords2 is empty.
    I have been pulling my hair out for days and days over this and as it is one of the first pages I am converting from mysql to mysqli I wonder if I am missing something very obvious to someone with more experience with the code.  I will be very grateful for any help, thank you in advance.

    You have intel graphics, that means the graphics cannot be upgraded.
    Welcome to the Toshiba user forums.
    For those of you who do not know what a user forum is, it is a community of users who volunteer time to help other users. Anyone can participate. It's 100% voluntary.
    Being super active is never a requirement

  • Using prepared statements in java

    Hi
    I have question on proper usage of prepared statements.
    PreparedStatement ps;
    public methoda(){
    ps=conn.prepareStatement(sqlQry);
    ps.setInt(1,2);
    ps.execute();
    In the above case I am creating new references to prepared statement (ps)each time I invoke methoda. So am I still using the advantage of prepared statements that is prepare a statement once and execute it multiple times. Or in the above case, the DB knows that this has been executed before and does not prepare it second time and just executes it.
    thanks

    The database stores execution plans for previous statements that were executed. So even tho you create a new PreparedStatement each time, it will still be an improvement.
    Even if you don't use prepared statements those plans are cached. Problem is that you must reuse the exact same sql to get the benefit.
    So if you do
    select password from users where user="dave";
    a hundred times, the database most likely will only create the plan once.
    Problem is of course, that
    select password from users where user="yelapa";
    is a completely different sql statement sofar as the database knows.
    Thus, the value of Prepared statements.
    select password from users where user=?
    is what the database sees no matter what user is running it.

Maybe you are looking for