Getting SQL errors with prepared statement in JDeveloper 10.1.3.2
I'm using oracle JDBC driver and I connect and update just fine from the SQL Worksheet in JDeveloper.
1) When I have more than 1 placeholder in my SQL statement, the last one is dropped so I get "Invalid column index".
2) When I add an extra one, it prepares OK but gets "ORA-01745: invalid host/bind variable name" on execution if the placeholder is inside the SQL closing paren (this situation is showed below).
3) When an extra one is outside the SQL closing paren, I get "ORA-00933: SQL command not properly ended"
I'm probably missing something obvious but here is the code I'm using:
public void insertToDB(Comment inrecord) throws Exception {
int idx = 0;
try {
this.initialize();
pstmt = conn.prepareStatement(
"INSERT INTO COMMENTS (COMMENT_ID, " +
"LOG_BUS_PROC_CDE, TYPE_CDE, SUBTYPE_CDE, " +
"REF_TYP_CDE, CREATE_USER, CREATE_DATE, " +
"UPDATED_USER, UPDATED_DATE, COMMENT_TEXT) VALUES(" +
"TO_TIMESTAMP('?','YYYY-MM-DD HH24:MI:SS.FF3'), ?, ?, " +
"?, ?, ?, TO_DATE(?,'MM/DD/YYYY'), NULL, NULL, ? ?)");
pstmt.setString(++idx,inrecord.getCommentID());
pstmt.setString(++idx,inrecord.getLogBusProcCDE());
pstmt.setString(++idx,inrecord.getTypeCDE());
pstmt.setString(++idx,inrecord.getSubTypeCDE());
pstmt.setString(++idx,inrecord.getRefTypCDE());
pstmt.setString(++idx,inrecord.getCreateUser());
pstmt.setString(++idx,inrecord.getCreateDate());
pstmt.setString(++idx,inrecord.getCommentTXT());
pstmt.executeUpdate();
conn.commit();
this.terminate();
catch (Exception e) {
conn.rollback();
this.terminate();
throw e;
}
Hi,
actually you increment the index
pstmt.setString(++idx,inrecord.getCommentID());
which means you never have an index of 0 but always start with 1
Frank
Similar Messages
-
Why do I keep getting an error with this statement
var Incentive = this.getField("Incentive").value;
var ETPC = this.getField("ETPC").value;
if (Incentive =< ETPC)event.value = Incentive;
else if (Incentive => ETPC)event.value = ETPC;That simple. works like a charm now. I can't thank you enough.
-
Error 01006 with prepared statement
I have the 1006 error with the statement:
prepstmt = conn.prepareStatement
select col from table where col = '?'
The parameter is set with setString().
I tried with the oracle 815 and 817 drivers.where i've to put STATEMENT.RETURN_GENERATED_KEYS?
I need to use executeUpdate()...I didn't put it anywhere. I just called the getGeneratedKeys() method without using that constant anywhere and it just worked. -
XML SQL format for Prepared statements in batch mode
Hi
I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
so i need to execute the prepared statements in one batch. Is the XML SQL format for prepared statements below correct ?to<root>
<stmt>
<Customers action="SQL_DML">
<access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
</access>
<key>
<NAME>IBM</NAME>
<ADDRESS>Street 3 </ADDRESS>
<KEYFIELD>CO</KEYFIELD>
</key>
<key>
<NAME>PWC</NAME>
<ADDRESS>Street 4 </ADDRESS>
<KEYFIELD>NO</KEYFIELD>
</key>
</Customers>
</stmt>
</root>
Please adviseHello Experts
Please throw some light on the above question.
Thanks in advance. -
Majority of times when I search for a particular web site I get the error message that states that "Firefox cannot find the server at ... " (site I am looking for)
I still have the problem although I uninstalled Mozilla (clearing the cache didn't work and neither did Word diagnostics), so have ended up thinking it could be Norton (the manual update worked x1) or Windows. Today I found an answer: disable the preview pane in Windows Explorer - there's a history of problems with this view.
-
when my lightroom opens up I keep getting an error message that states, "Lightroom encountered an error whne reading from its preview cache and needs to quit" I have relaunched it a number of times and keep getting the same message. Any thoughts on how to fix this?
You need to delete your preview cache and have Lightroom rebuild it. Cache location can be found here.
https://helpx.adobe.com/lightroom/kb/preference-file-locations-lightroom-41.html
Why And How To Clear Your Lightroom Cache - Lightroom Fanatic -
I just downloaded itunes onto my new laptop and I am trying to burn songs onto a cd that I had purchased previously and I am getting an error message that states I must authorize this computer. What does that mean?
If the computer's running Mac OS X, move the cursor to the very top of the computer's screen, click on Store, and choose Authorize this Computer.
If the computer's running Windows, press the Alt and S keys and choose Authorize this Computer, or click here, follow the instructions, click on Store in the menu bar, and choose Authorize this Computer.
(95452) -
Keeping getting an error with-in the App Store. Error 100 saying that my payment can't be received at the time. I updated to Mountain Lion to download the new Logic Pro X. Now left with now recording software and it's not letting me buy the new one.
iMac, OS X Mountain Lion (10.8.4), trying to get Logic Pro XHello jst84,
The following article may be helpful in getting your purchase to complete.
Mac App Store: "An unknown error occurred (100)" when purchasing
http://support.apple.com/kb/TS3637
Cheers,
Allen -
I cannot log into iCloud using my Apple username and password. I keep getting an error message that states "CANNOT SIGN UP - The Apple ID is valid but is not an iCloud account." How do I fix this?
You are getting this message because you are attempting to create an iCloud account on a PC. You can only create iCloud account on an iOS device (iPhone, iPad or iPod Touch) running iOS 5 or higher, or on a Mac running OS X Lion (10.7.2) or higher. After creating your account on one of these devices you will then be able to sign into the account on your PC.
-
I need help download software for my Ipad. I get an error message that states "the network connection timed out"
Disable or Turn off you firewall and and anti-virus software and try the download again.
Stedman -
Autogenerated key with Prepared Statement...
Hi guys,
i've a question and i need help...
how can i retrieve autogenerated key with prepared Statement?
I see examples only about statements...please post me example code..where i've to put STATEMENT.RETURN_GENERATED_KEYS?
I need to use executeUpdate()...I didn't put it anywhere. I just called the getGeneratedKeys() method without using that constant anywhere and it just worked. -
When installing Premiere Elements I get an error with Shared Technologies
When installing Premiere Elements onto a Windows XP Service Pak 3, I get an error with Shared Technologies.
Hi,
Thx for the reply.
I had Bridge open in background and once I closed that Elements installed correctly.
Thank you. -
When I plug my hdmi lightening converter into my iphone5 I get an error message that states " downloading accessory firmware. Your accessory will not function until download completes. How can I fix this?
Don't know what changed today but it downloaded and installed on the shuffle. So far so good.
-
What is a user parameter list in iMovie? I am trying to sent the movie from imovie to idvd and I keep getting an error with the user parameter list. Help?
Can you give more details? What exactly is the entire error message text? there should be an error number too. Are you trying to finalize this to an external disk?
-
Can some one HELP me , I keep getting this error with my Time Machine Back up, "The backup disk image “/Volumes/JKPN Safe/JKPN IMAC.sparsebundle” is already in use.
See > http://pondini.org/TM/C12.html
Maybe you are looking for
-
Itunes will not show up on my computer, no matter how many times I've downloaded it
I tried downloading Itunes 10.7, and it says "thank you for downloading itunes." and yet it is no where to be found on my computer. I am using windows 7, 64 bit laptop, and it says that it is the 64 download... I do not currently have any form of itu
-
so i connected my ipod shuffle to my apple computer and the status light on my ipod shuffle shows that it is charging but when i look for it on the pc dock or in itunes it doesn't show it at all.... so what do I do???
-
TS1702 I am battling to switch from the US store to the SA to update apps or have new ones installed
I am currently visiting the US and I was trying to install new apps and update existing ones but the system keeps bumping me out saying I need to switch to the SA store but I can't figure out how to do that
-
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2755.
-
Pricing schema does not sum two quantities
Dear all, Pricing schema does not sum two quantities 300 0 NETW 301 0 OWST 210 210 302 0 YOKI 300 301---Here I expext from SAP to sum NETW and OWST. However it does not do it. How can I