Handling ' and " in a Prepared Statement
Hi,
I am using a prepared statement (WebLogic Portal Server having JDBC communication with MS SQL server)
I HAVE to pass a string like '"*ABC*"'
i.e. <single quote><double quote>*ABC<double quote><single quote>
If i hard code this value within the prepared statement it works.
If i try to pass it as argument it fails.
In my case the user may submit any string value in the place of ABC
Kindly advise
regards
-Ramudu
You're probably trying to include the quotes in the prepared statement and pass the ABC as the text to substitute for the question mark. It doesn't really work like that. It's all or nothing. Create your parameter like this:
public String quoteWrapper(final String unwrappedParameter) {
return "'\"*"+unwrappedParameter+"*\"'";
}
Similar Messages
-
How do I handle NULL returns from prepared statement?
Thanks in advance to all those who respond. As a beginner with Java/JSP/JDBC, I need all the help I can get!
Here's the problem...
I'm using a prepared statement in JSP to query a MySQL database.
If there is a value to return, everything works properly.
If the query returns a NULL (empty set) value, I get the following error:
javax.servlet.ServletException: Before start of result set
Here's the code (no negative comments please...I know I'm violating some conventions! I'll restructure it later. Right now I just need help with handling the NULL case):
<%
Driver DriverAppt = (Driver)Class.forName(MM_test_DRIVER).newInstance();
Connection ConnAppt = DriverManager.getConnection(MM_test_STRING,MM_test_USERNAME,MM_test_PASSWORD);PreparedStatement StatementAppt = ConnAppt.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id = " + Recordset1__MMColParam + " AND year = " + yy + " AND month = '" + months[mm] + "' AND date = " + dates[dd] + " AND appttime = '16:15:00'");
ResultSet Appt = StatementAppt.executeQuery();
boolean Appt_isEmpty = !Appt.first();
boolean Appt_hasData = !Appt_isEmpty;
Object Appt_data;
int Appt_numRows = 0;
%>
Thanks for the help!!!I think I have a better handle on what's occurring here. To cut to the heart of the problem, I'm going to give a very simple example that illustrates what type of error handling I need.
HERE'S THE EXAMPLE:
Let's say that I have a database of users. There are only two columns in the database: user_id and lastname. There are only 2 users, user_id "1" has lastname "Jones" and user_id "2" has lastname "Smith".
I built a very simple web interface that let's a user enter a number to see if there's a lastname associated with that record. The user has no way of knowing if the user_id exists or not, so they may or may not enter a valid number.
If the user enters a valid user_id (in this case "1" or "2"), then the correct lastname is displayed. If the user enters an invalid user_id (in this case, anything other than "1" or "2") then I get the same "Before start of result set" error that I'm getting in my real application.
So, the question is: WHERE IN THIS CODE WOULD I HANDLE THE RETURN OF AN EMPTY SET?
The goal here is to have the sentence say "The user's lastname is .", basically returning null. If there has to be a value, then have the last sentence say "The user's lastname is unknown."
If you can solve this simple example, you'll have also solved the problem with my main application!!!! :-)
Here's the example code:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/example.jsp" %>
<%
String Recordset1__MMColParam = "1";
if (request.getParameter("user_id") !=null) {Recordset1__MMColParam = (String)request.getParameter("user_id");}
%>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_example_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_example_STRING,MM_example_USERNAME,MM_example_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM test_table WHERE user_id = " + Recordset1__MMColParam + "");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="test.jsp" method="get" enctype="application/x-www-form-urlencoded" name="form1" target="_self">
<p> Submit a user id and a lastname will be displayed.</p>
<p>
<input type="text" name="user_id">
<input type="submit" name="" value="Submit">
</p>
</form>
<p>The User's lastname is <%=(((Recordset1_data = Recordset1.getObject("lastname"))==null || Recordset1.wasNull())?"":Recordset1_data)%>.</p>
</body>
</html>
<%
Recordset1.close();
StatementRecordset1.close();
ConnRecordset1.close();
%>
A huge "THANK YOU!!!!" to all those who've helped me here!!! -
? 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. -
Using partition in prepared statement
Hello,
I am connecting to an oracle 9i database and write a prepared statement like
String query = "SELECT * FROM ADM.TABLE1 PARTITION (TABLE1_?)";
PreparedStatement pstmt = dbConnection.prepareStatement(query);
pstmt.setString(1, "20" + callDate); // Partitions are like TABLE1_20030605
ResultSet rs = pstmt.executeQuery();
I get this error ORA-00933: SQL command not properly ended
Any ideas if i am substituting the value correctly or if this is the right way to use prepared statement ?It is the wrong way to use a prepared statement.
You will need to create the string dynamically. -
Urgent: Prepared Statement
Hi Friends,
I am doing update using Prepared statement. I have one date field in where clause. And the value of date field is null. e.g. where clr_dte is null.
In my code I'm using ps.setNull(1, Types.DATE);
But it is not working. I'm getting null resultset back.
Can anybody tell me what am i doing wrong ?
I would appreciate your help.
Thanks in advance.
-PriyaHere is my query statement & below that my prepare statement. Please see the bold part.
Thanks.
update tnr134_pyb_rcv_shr " +
"set updt_tsp = ? " +
", updt_usr_id = ? " +
", bulk_req_id = ? " +
"where ANNC_SMRY_ID = ? " +
"and BBH_SECR_NUM = ? " +
"and BBH_SECR_CRT_TSP = ? " +
"and CLNT_ACCT_NUM = ? " +
"and CLNT_CKDGT_NUM = ? " +
"and CLNT_SFX_CDE = ? " +
"and CLNT_PRFX_CDE = ? " +
"and SOD_ACCT_NUM = ? " +
"and SOD_CKDGT_NUM = ? " +
"and SOD_SFX_CDE = ? " +
"and SOD_PRFX_CDE = ? " +
"and REG_CDE = ? " +
"and PY_PREF_NUM = ? " +
"and POSN_STAT_CDE = ? " +
"and PY_PREF_ITEM_NUM = ? " +
"and PY_SEQ_NUM = ? " +
"and PYB_RCV_CDE = ? " +
"and CLR_DTE = ? " +
"and STLMT_DTE = ? " +
"and ACRL_DTE = ? " +
"and py_seq_item_num = ? " +
"and updt_tsp <= ? " +
"and curr_state_cde in (select oper_subsys__st_id " +
"from tnr113_st_to_stat " +
"where dsply_txt = 'Open' " +
"and dsply_typ_cde = 'PAY' " +
"and oper_subsys_id = 5)";
Prepared statement
argPs.setTimestamp (1, argUpdateTsp); // updt_tsp
argPs.setString (2, getUserId()); // updt_usr_id
argPs.setString (3, getBulkRequestId()); // bulk_req_id
argPs.setInt (4, Integer.valueOf(argVariables[8]).intValue()); // annc_smry_id
argPs.setString (5, argVariables[2]); // bbh_secr_num
argPs.setTimestamp (6, java.sql.Timestamp.valueOf(argVariables[9])); // bbh_secr_crt_tsp
argPs.setBigDecimal (7, new java.math.BigDecimal(argVariables[3])); // clnt_acct_num
argPs.setBigDecimal (8, new java.math.BigDecimal(argVariables[10])); // clnt_ckdgt_num
argPs.setString (9, argVariables[11]); // clnt_sfx_cde
argPs.setString (10, argVariables[12]); // clnt_prfx_cde
argPs.setBigDecimal (11, new java.math.BigDecimal(argVariables[13])); // sod_acct_num
argPs.setBigDecimal (12, new java.math.BigDecimal(argVariables[14])); // sod_ckdgt_num
argPs.setString (13, argVariables[15]); // sod_sfx_cde
argPs.setString (14, argVariables[16]); // sod_prfx_cde
argPs.setString (15, argVariables[6]); // reg_cde
argPs.setShort (16, Integer.valueOf(argVariables[7]).shortValue()); // py_pref_num
argPs.setString (17, argVariables[17]); // posn_stat_cde
argPs.setShort (18, Integer.valueOf(argVariables[19]).shortValue()); // py_pref_item_num
argPs.setShort (19, Integer.valueOf(argVariables[25]).shortValue()); // py_seq_num
argPs.setString (20, argVariables[24]); // pyb_rcv_cde
if(argVariables[21] == null || argVariables[21].equals("null")){
argPs.setNull(21,java.sql.Types.DATE);
else{
argPs.setDate (21, java.sql.Date.valueOf(argVariables[21])); // clr_dte
if(argVariables[22] == null || argVariables[22].equals("null")){
argPs.setNull(22,java.sql.Types.DATE);
else{
argPs.setDate (22, java.sql.Date.valueOf(argVariables[22])); // stlmt_dte
if(argVariables[23] == null || argVariables[23].equals("null")){
argPs.setNull(23,java.sql.Types.DATE);
else{
argPs.setDate (23, java.sql.Date.valueOf(argVariables[23])); // acrl_dte
argPs.setShort (24, Integer.valueOf(argVariables[26]).shortValue()); //py_seq_item_num
argPs.setTimestamp (25, java.sql.Timestamp.valueOf(argVariables[18])); // max(updt_tsp) -
Prepared Statement Insert and null handling
This is my statement and questions after the statement I will give my questions
StringBuffer sql = new StringBuffer();
sql.append("INSERT INTO CSD.TCLAIM");
sql.append(" (BENEFIT_REQUEST_ID,BRLI_NB,BRLI_VOID_IN,BILLING_END_DT,CLIENT_ID,");
sql.append(" CDH_BENEFICIARY_ID,PT_BENEFICIARY_ID)");
sql.append(" VALUES ");
sql.append("(" + claim.getBrt() + "," + claim.getBrli() + "," + claim.getBrliVoid() + "," + claim.getBillingEndDate() + "," + claim.getClientID() + ",");
sql.append(claim.getCdhBeneID() + "," + claim.getPtBeneID() +")");
String query = sql.toString();
PreparedStatement statement = cpConn.prepareStatement(query);
statement.executeUpdate();
T
I am not using setString() or setInt(). The string columns (CDH_BENEFICIARY_ID) does not contain the single quote and insert fails. Is there any way to insert the single quote without calling a method like formatAsString() ?
Next question is column like CLIENT_ID which is defined in the database as integer can contain null. How do I handle those columns. Do I have to do anything special when I encounter a null in an int or double columns.
I am using JDBC 2.0 and UDB in SP environment. I have seen people wrap some columns to Wrapper class and do something like this while reading from database
claim.setClientID(new Integer(rs.getInt("CLIENT_ID")));
if (resultset.wasNull) {claim.setClientID(null)) };
Is there a beter way?
This will force us to define claim.client_id as Integer. I want to define client_id as int and handle null values.
Is there any way to insert the single quote You escape a single quote by replacing each occurrance with two single quotes. Presumably your strings already have single quotes around - if not you need to add them.
...can contain null. How do I handle those columns...update mytable set client_id=null where....
insert into mytable (client_id) values(null)
Is there a beter way?Not really. -
Could not find prepared statement with handle %.
Greetings. I've seen several posts for this error on the web, but no clear cut answers. I captured the code below in profiler, with the intention of replaying in mgmt studio.
However, the attempt end in the following error: "Could not find prepared statement with handle 612."
declare @p1 int
set @p1=612
declare @p2 int
set @p2=0
declare @p7 int
set @p7=0
exec sp_cursorprepexec @p1 output,@p2 output,N'@P0 int,@P1 int,@P2 int,@P3 int,@P4 bit',N'EXEC dbo.mySproc @P0,@P1,@P2,@P3,@P4 ',4112,8193,@p7 output,219717,95,NULL,1,0
select @p1, @p2, @p7
Something noteworthy is that my sproc only has 5 input parameters, but this makes it look like it has many more.
How do I manipulate the code enough to make it work in mgmt studio? Thanks!
TIA, ChrisRDBAIn profiler you would normally see RPC:Starting and RPC:Completed. The statement shown in RPC staring is what you need to pick because as Erland explained, completed would show "funky" behavior.
Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
This posting is provided "AS IS" with no warranties, and confers no rights.
My Blog |
Team Blog | @Twitter
Author: SQL Server 2012 AlwaysOn -
Paperback, Kindle -
Oracle Prepared Statement and spaces in field
I have a field that is defined as char(10). It has characters like '39' in it. When I select against it using standard SQL (where clause) I get results. When I use it in the where clause of a prepared statement it does not return any rows.
If I have the field defined as char(2) the prepared statement works.
If I have the field defined as varchar2(10) and loaded with '39' the prepared statement works.
If I have the field defined as varchar2(10) and loaded with '39 ' the prepared statement returns no results.
I really do not think this is a JDBC problem. However, since Oracle's site basically <expletive deleted>, I am hoping someone here has a solution.
Thanks in advance if you can help.Let me clarify.
I cannot remove the whitespace from the data in the database. I do not need the whitespace to do the query if I am not using a Prepared Statement. This seems to be a problem with the way Oracle is handling the prepared statement. (hence.. my thinking that this is really not a JDBC problem at all.. but I could be wrong.) -
Could not find prepared statement with handle 13
Hi,
I'm having a terrible problem: When I try to execute a SQL Query the following exception is thrown:
* "java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 13."
This exception is thrown is this line:
boolean returnResultSet = ((PreparedStatement)sqlStatement).execute();
The sqlStatement object is a java.sql.PreparedStatement that was received as a Statement in the method definition.
The following query is being executed in this PreparedStatement:
SELECT id_promocao, ds_nome, id_tipo, ds_sinopse, dt_lancamento, pt_site, pt_caminho_relativo, fl_ativo FROM TAB_CINE_GM ORDER BY ds_nome
I'm using Macromedia JRun 4 build 61650 and I'm using MS-SQL Server 2000 as a database server.
If anyone can help, I'll thanks a lot.
Helcio Chaves
S�o Paulo - SP - Brazil
[email protected]There is a common way to check runtime type:
if (sqlStatement instanceof PreparedStatement)
returnResultSet = ((PreparedStatement)sqlStatement).execute();
else
returnResultSet = sqlStatement.execute();
}By the way - I can't understand why you're trying to cast sqlStatement to PreparedStatement? It doesn't matter at all due to so-called polymorphism of all Java methods (except static ones). Anyway execute() will run for PreparedStatement but bot for Statement
Enjoy,
Pavel -
FindByPrimaryKey: Could not find prepared statement with handle 3
I've inherited a WL61 application and been asked to make it work under WL81. We're using SQL Server 2000. We only access two tables. The XML got auto-converted during the upgrade, but I had to correct the RDBMS column names in the weblogic-cmp-jar.xml
The application mostly works except the findByPrimaryKey fails with:
ERROR ExecuteThread: '14' for queue: 'weblogic.kernel.Default' Administrator : TargetSessionBean - Error finding promotion with ID <2>
javax.ejb.FinderException: Problem in findByPrimaryKey while preparing or executing statement: 'weblogic.jdbc.wrapper.PreparedStatement_weblogic_jdbc_base_BasePreparedStatement@95':
java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 3.
java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 3.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
I've checked the database table and the row exisits with the appropriate PK (in this case a promotion with ID <2>).
In the WL61 version the findByPrimaryKey was explicitly defined in the weblogic-cmp-rdbms-jar.xml as follows:
<finder>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>com.fujitsu.ftxs.corema.server.PromotionPK</method-param>
</method-params>
<finder-query><![CDATA[ (= $0 promotionId) ]]></finder-query>
<finder-expression>
<expression-number>0</expression-number>
<expression-text><![CDATA[@0.promotionId]]></expression-text>
<expression-type>int</expression-type>
</finder-expression>
</finder
But I understand that with WL81 I should no longer define this - it's done implicitly - so I've removed this finder definition.
Any help appreciated. Thanks,
- Andy AbelI fixed it by switching from the using the BEA driver:-
DriverName="weblogic.jdbc.sqlserver.SQLServerDriver"
URL="jdbc:bea:sqlserver://host:1433"
And using the Microsoft Driver instead:-
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url=jdbc:microsoft:sqlserver://host:1433
If anyone can explain why the Microsoft Driver works and the BEA driver does not I'd like to know.
Thanks,
- Andy Abel -
Could not find prepared statement with handle 1.
[Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 1.
I'm getting this error message in what appear to be random ways. The first time I look at a page I might not get it, but the second time I might. I discovered that removing a cfqueryparam tag worked, but that is not really a safe solution. I checked that the cf_sql_type matched the database field, and in one case changed a cf_sql_varchar to a cf_sql_char so it would match a SQL Server nchar(10) field. But still these errors. Any ideas? I've not had any luck Googling this.
I should add that I'm running Coldfusion 9 as a Tomcat webapp on a Linux server. The database is SQL Server 2005, I think.Here's the one that is breaking now:
<cfquery name="CheckCredentials" datasource="#application.crossreg_dsn#">
SELECT [name_first]+' '+[name_last] as name
,p.[uni]
,p.email
,p.role_id
,r.role_name
,p.external_program_id
FROM [CrossReg].[dbo].[People] p
INNER JOIN dbo.Roles r on r.role_id = p.role_id
WHERE uni = <cfqueryparam cfsqltype="cf_sql_char" value="#Session.username#">
</cfquery>
Session.username is being returned from a CAS authentication system. I've never had troubles with it before. -
Connection/ResultSets/Prepared Statement opening and closing
Hi all another question that was sparked by a thread that I recently read. I believe it was duffmo who got the code from jverd. The code I am referring to is to have an open and close connection specified in a Utility or Database class. I wanted to know if there was any issues with having methods that open and close connections/result sets/ preparedStatements. Currently I am putting the finally blocks inside each of my methods. There is obvious benefits to putting the methods in a class on their own (namely code re-use) but I wanted to know if there are any dangers. (This may seem like a dumb question, but I've found from experience it's the things that you don't know that will cost you loads of time).
thanks again.Hi all another question that was sparked by athread
that I recently read. I believe it was duffmo who
got the code from jverd. Generally speaking it's fine.
But as always you may have some long term design
issues to think about. If you build a simple
framework that consists of one class and that does
all that your program does then great.
Once you start add more complexity though you'll want
to be careful that you aren't reinventing the Spring
wheel or even ending up implementing your own
connection pool. Both of which, judging from posts
here seem to happen from time to time.
So I guess all in all, yes it's much better than
scattering the code all about but depending on what
you are going to be doing with it you may want to
look at the various ORM frameworks to see if they are
really the direction you should be going in.Thanks for the information cotton. I just wanted to make certain that it was a sensible thing to do. When I had first asked about connections I was told they should be opened an closed in the same spot, unfortunately I took that explanation a little too much to heart, and started opening and closing every connection resultset and prepared statement in each of the DAO classes that I was using.
Guess it's going to be a bit of work to refactor, but worth it for the cleaner code that will result. -
Error handling in prepared statement batch
Hi,
For a prepared statement batch, it is not possible to know which operation failed. ... You should always perform a ROLLBACK operation in this situation.
For a generic statement batch or callable statement batch, the update counts array is only a partial array containing the actual update counts up to the point of the error. ... You can either commit or roll back the successful operations in this situation, as you prefer.
-- http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/oraperf.htm#1056233
But, I want to skip failed operations and continue to excecute the remains of the batch, also, I want to improve application performance, what should I do? Is there any choice?
Best Regards,
Kevin ZhaoAccording to the Oracle docs these are not the only possible values:
Oracle9i JDBC Developer's Guide and Reference
Release 2 (9.2) chapter 12
Performance Extensions
"For a prepared statement batch, it is not possible to know which operation failed. The array has one element for each operation in the batch, and each element has a value of -3. According to the JDBC 2.0 specification, a value of -3 indicates that an operation did not complete successfully. In this case, it was presumably just one operation that actually failed, but because the JDBC driver does not know which operation that was, it labels all the batched operations as failures."
It goes on to say that for a generic statement batch it is possible to know which failed. I would like to know if similar functionality will be available for prepared statement batches in the future. -
Statement and Prepared Statement
if i write a same query with statement and preparedStatement
like
Select * from emp_detail where emp_id =20;
stmt= con.createStatment();
rs = stmt.executeQuery(query);
and using preparedStatement
Select * from emp_detail where emp_id =?;
pstmt= con.prepareStatement();
pstmt.setInt(1,20);
rs = stmt.executeQuery(query);
Using which statment(Statement or Prepared Statement) the data will retrive fast and why.... in these case ????Statement should be quicker than Prepared Statement, because
Statment do only one thing: send that sql to server or run that sql directly.
Prepared Statement should do two (or more than two)things:
1. parse your sql first, prepare a store procedure, then call that store procedure.
Or
2. prase your sql first, then use your value to replace "?" for getting a new sql, then work like Statement.
Prepared Statement is quiker when you use it repeatedly. -
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.
Maybe you are looking for
-
FA Acquisition - 21151: error while posting asset document: '100000006'
Hi All, When I was performing the FA Acquisition for a fixed asset code, the above error message prompt. I am using SAP B1 8.8 PL 15. Before this error appear, I was able to perform all other transactions like FA Acq, Credit Note, Retirement and depr
-
How can I add a custom property to an object, like a paragraph?
Hi, We have a merge process that combine multiple document into one and I need to store the filename of the imported file at the beginning of each merge point. Each document that we merge contains a Title paragraph and I was wrongly assuming that I
-
Had BB 8350 for a year, but now it has network issues??
I use a data plan on my BB and also use it to tether to my laptop (using VZAccess). Recently, I've been getting the message on my BB "Insufficient network coverage..." when attempting to use the browser.My service will flop between 1X-3G service. Eve
-
How do I make the answer boxes not print out solid black?
Does anyone know how to change the settings on the Form so that the boxes do not print out solid black?
-
i had the service with atta while ago,however, i never upgraded it to the new software bec ,i still use like i pod,now whenever iwant todownload sth. it tells you need to update your version of software,however, im scared if ido my i phone would be l