StringIndexOutOfBoundsException in CallableStatement
Hi, I fell several times into following error:
java.lang.StringIndexOutOfBoundsException: String index out of range: 17
at java.lang.String.charAt(String.java:558)
at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:877)
at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:811)
at oracle.jdbc.driver.OracleSql.getSql(OracleSql.java:284)
at oracle.jdbc.driver.T2CConnection.open(T2CConnection.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3093)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4286)
at sk.transacty.cm_iface.bw3_ai.bc4j.jpub.Test.main(Test.java:12)
Problem is the missing closing curly brace in my code:
CallableStatement st = conn.prepareCall("{?=call test_addr"); // incorrect
CallableStatement st = conn.prepareCall("{?=call test_addr}"); // correctIt took me quite long to find the reason, this post is for anyone falling into the same trouble...
Viliam
Hi,
Did you attach a resource to service?
Is that resource pointing to BSP application?
--Naga
Similar Messages
-
Unable to execute an update statement using CallableStatement
Hi there,
I'm trying to run an update statement from JUnit using java.sql.CallableStatement and oracle.jbo.server.DBTransaction.
String updateSql =
"update footable set barcol=TO_DATE('12-SEP-09','dd-MM-yy') where bazcol = 505";
try {
statement =
applnModule.getDBTransaction().createCallableStatement(updateSql,
2);
int executeUpdate = statement.executeUpdate();
AppsLogger.write(this,
"# records UPDATED ------------------>" + executeUpdate,
AppsLogger.SEVERE);
} catch (SQLException s) {
s.printStackTrace();
Assert.fail("Encountered SQL Exception: " + s);
} finally {
try {
if (statement != null)
statement.close();
} catch (SQLException s) {
}Below is the exception I get when I run the above code. There is no problem with the SQL - it works fine from SQLDeveloper.
java.lang.AssertionError: Encountered SQL Exception: java.sql.SQLDataException: ORA-01858: a non-numeric character was found where a numeric was expected
org.junit.Assert.fail(Assert.java:91)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:105)
org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.invokeTestMethod(AtfJUnit4JTestCaseClassRunner.java:362)
oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.runMethods(AtfJUnit4JTestCaseClassRunner.java:272)
oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner$1.run(AtfJUnit4JTestCaseClassRunner.java:265)
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.run(AtfJUnit4JTestCaseClassRunner.java:262)Edited by: 911023 on Oct 2, 2012 11:28 AM
Edited by: 911023 on Oct 2, 2012 11:30 AMUsing case statement.
UPDATE gor_gold_post
SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
OR
(TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
THEN 1
ELSE 99
END,
b49n = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
OR
(TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
THEN 1
ELSE 99
END
WHERE tariff_code IN (169, 135, 136);Note: Code not tested. -
CallableStatament for selection stored procedure
hello,
i write a jsp page where there are inputs. when i click on a button i want to search elements in my sql server database. to do that, i call a stored procedure :
CREATE PROCEDURE PS_ELTS
@param0 VARCHAR(40),
@param1 VARCHAR(10),
@param2 VARCHAR(6),
@param3 VARCHAR(6),
@param4 VARCHAR(40)
AS
SELECT ELTS.NAME,
ELTS.TEL,
ELTS.ADR1,
ELTS.ADR2,
ELTS.SERV
FROM ELTS
WHERE (ELTS.NAME LIKE @param0 OR @param0 IS NULL)
AND (ELTS.TEL LIKE @param1 OR @param1 IS NULL)
AND (ELTS.ADR1 LIKE @param2 OR @param2 IS NULL)
AND (ELTS.ADR2 LIKE @param3 OR @param3 IS NULL)
AND (ELTS.SERV LIKE @param4 OR @param4 IS NULL)
ORDER BY ELTS.NAME, ELTS.TEL
i have a java class elts as business object. in the class, there is a method search which takes an elts event, connects to the database and gets elements which are ok. if all parameters are null, i get every lines of ELTS table. it's ok. if one or more of the parametre is not null, i don't get any line. this is the method :
public void search(UtilBean bean) throws Exception {
int i = 0;
Class.forName(driver);
Connection connection = DriverManager.getConnection(url, login, password);
if (connection != null) {
connectionOk = true;
this.setNAME(beanrecherche.getNAME());
this.setTEL(beanrecherche.getTEL());
this.setADR1(beanrecherche.getADR1());
this.setADR2(beanrecherche.getADR2());
this.setSERV(beanrecherche.getSERV());
String aProc = "{call PS_ELTS(?,?,?,?,?)}";
CallableStatement aStatement = connection.prepareCall(aProc);
aStatement.setString(1, fmt_sqlChaineLike(this.getNAME()));
aStatement.setString(2, fmt_sqlChaineLike(this.getTEL()));
aStatement.setString(3, fmt_sqlChaineLike(this.getADR1()));
aStatement.setString(4, fmt_sqlChaineLike(this.getADR2()));
aStatement.setString(5, fmt_sqlChaineLike(this.getSERV()));
aStatement.execute();
ResultSet rs = aStatement.getResultSet();
while (rs.next()) {
i++;
UtilBean util = new UtilBean();
util.setNAME(rs.getString("NAME"));
util.setTEL(rs.getString("TEL"));
util.setADR1(rs.getString("ADR1"));
util.setADR2(rs.getString("ADR2"));
util.setSERV(rs.getString("SERV"));
listUtil.add(util);
do i do something wrong ? is there a solution to this problem ?i found what's wrong. in my stored procedure, i defined parameters like this :
@param0 VARCHAR(40),
@param1 VARCHAR(10),
@param2 VARCHAR(6),
@param3 VARCHAR(6),
@param4 VARCHAR(40)
when i use :
aStatement.setString(1, this.getNAME());
java sends a 40 characters long string to the stored procedure so if i write 'hello', the stored procedure gets 'hello '. any element is like that in the database so i must change the stored procedure :
(ELTS.NAME LIKE @param0 OR @param0 IS NULL) became (ELTS.NAME LIKE rtrim(ltrim(@param0)) OR @param0 IS NULL) -
SQL Injection on CallableStatement
I will try to post this all in one line, as the tags are not working today. I know that one should use PreparedStatement over Statement to obviate the thread of a SQL injection attack. Is CallableStatement vulnerable as well? For reference, this would be running against an Oracle RDBMS. Thanks!
- SaishI guess there is no hard-and-fast rule.Well, I guess the hard and fast rule is "only use
bound variables". If you've got a sane database
design then that shouldn't cause you any problems.
Dave.I agree. I was approaching the issue mainly from a security perspective in locking down a legacy system against SQL injection attacks. Using Eclipse, I was able to zero-in on usages of Statement fairly easily. But the more I looked into CallableStatement, the more I realized that I woud have to inspect each invocation manually. (Just in case someone did not bind variables or built a dynamic SQL string).
- Saish -
Help needed in debugging callablestatement changing performance
Looking for some help debugging a performance problem.
We are in the process of converting an ASP web application running on IIS to a java web application running on OAS. We have java code using a CallableStatement that calls an Oracle PL/SQL Procedure that runs inserts and updates as needed and does not return anything.
When the Java application calls the procedure using the same parameters and doing the exact same work the execution time is either 3 minutes or 30 minutes. We have narrowed down the location of the slowdown and when it takes 30 minutes to execute it appears to be hanging during a cursor execution. What would cause the execution times to vary so much?
Here's another piece to the puzzle. When the procedure is called from IIS with the exact same parameters that were used from OAS the procedure ALWAYS runs in 3 minutes. Why would IIS performance be so consistent and OAS so inconsistent?
Any debugging suggestions would be greatly appreciated.
Thanks,
Bobuser4908334 wrote:
We are in the process of converting an ASP web application running on IIS to a java web application running on OAS. We have java code using a CallableStatement that calls an Oracle PL/SQL Procedure that runs inserts and updates as needed and does not return anything.
More information is needed on that.
There is one proc or 50?
The proc is being called one time or 50 times?
You are not using Batching right?
When the procedure is called from IIS with the exact same parameters that were used from OAS the procedure ALWAYS runs in 3 minutesYou are running the java server on exactly the same box as IIS?
The java code is using exactly the same database as IIS? (Did you verify this?) -
Receiver FTP adapter java.lang.StringIndexOutOfBoundsException
Hi,
i'm getting the following error trying to reach an FTP server using a Receiver CC:
Attempt to process file failed with Error occurred while connecting to the FTP server "xxxxxx:21": java.lang.StringIndexOutOfBoundsException
Any help would be really appreciated
Thanks
Simona MilioneHi
check the fixedFieldLength parameter for all the fields in you File COntent COnversion
there is some field whose length is greater than what you specified in FCC
regards
krishna -
Java.lang.StringIndexOutOfBoundsException when executing query on Oracle 9i
SQL Deverloper Build 1467
Windows XP
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
I have the following query being executed in SQL Worksheet.
select * from address
where address_id in (1, 2, 3, .... 1000, 1001);
If I have <= 1000 expressions, it executes but if it has > 1000, the query does not return this error "ORA-01795: maximum number of expressions in a list is 1000". When I ran this it in console, it gave me this error. In oracle 10G it works fine.
java.lang.StringIndexOutOfBoundsException: String index out of range: 16058
at java.lang.String.substring(String.java:1765)
at oracle.dbtools.raptor.scriptrunner.SQL.run(SQL.java:73)
at oracle.dbtools.raptor.scriptrunner.ScriptRunner.run(ScriptRunner.java:116)
at oracle.dbtools.raptor.scriptrunner.ScriptRunner.run(ScriptRunner.java:186)
I think this is a bug in the 9i module.
-NagsAnil kumar wrote:
Hi,
Thanks for your reply. Could you please explain your solution in detail?Hi,
I just have a try...
create table t (id int,my_lob clob)
begin
insert into t values(101,'Oracle redwood shores USA');
insert into t values (102,'HP palo alto USA');
insert into t values(103,'Capgemini FRANCE');;
end;
create index my_idx on t(my_lob) indextype is ctxsys.context
select *
from t
where contains(my_lob,'USA',1)>0
Output
ID MY_LOB
101 Oracle redwood shores USA
102 HP palo alto USA Hope it helps,
CKLP -
How to use CallableStatement for StroredProcedure in java?
I've successfully created storedProcedure for select comment in mysql.but how implement in java code with using of CallableStatement.Pls help me
Message was edited by:
SKVenkatestry this in main:
try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch (Exception exc) {System.err.println("Eroare la incarcarea look & feel" + exc);} -
Getting error in cursor variable in CallableStatement
Hi,
I am trying to retrieve result set from PL/SQL procedure using cursor variable.
but I getting error sometime.
this is code in my program...
CallableStatement pstmt=null;
pstmt = con.prepareCall("{call Crms2.SearchRNameTime(?,?,?,?,?,?)}");
pstmt.setString(1, uid);
pstmt.setString(2, strBookingDate);
pstmt.setInt(3, roomid);
pstmt.setInt(4, lngStartTime);
pstmt.setInt(5, lngEndTime);
pstmt.registerOutParameter(6, oracle.jdbc.driver.OracleTypes.CURSOR ); // error accured in this line
pstmt.execute();
rs = (ResultSet)pstmt.getObject(6);
error was accrued at line : pstmt.registerOutParameter(6, oracle.jdbc.driver.OracleTypes.CURSOR );
error is: orable.jdbc.driver can not resolve tha symbol..
but it some time executing , some time giving error.
it is require any package to import?
please help me on this problem.
regards
Narru990187 wrote:
i have created a cursor to return only 5th row from a table .
declare
cursor cur is select * From(select last_name,salary,rownum rn from employees where rownum<=50)) where rn=5;
just a side note, (others have helped with the actual error already), using "rownum" like you do isn't very consistent. Not really sure about the requirment of "5th row", but no matter. Just keep in mind that the way Oracle assigns a rownum, and the fact you have no sorting/order ... you are - effectively - getting a random row. That is, with no data changing, Oracle may very well retrieve things in a different order due to index, new oracle version, whatever.
If you do actually need the 5th row where you have some sorting (ie 5th largest salary, or 5th record by last name, etc. ), then you may want to consider something like:
select * from (select last_name, salary, row_number() over (order by salary desc) rn from employees) where rn = 5;
or whatever your sort criteria is. Do a search for "Top N" queries if you need more info.
It'll work a bit more consistently. -
MP Error: StringIndexOutOfBoundsException: String index out of range: -1
Hi All,
We are using PI 7.1 EHP1, Where in we would like to see the capabilty of User-Module for Conversion of IDoc Messages Between Flat and XML Formats. Gone thru the blog (/people/sap.user72/blog/2005/07/04/get-into-the-zone - Part 2) and maintained the necessary NWA configurations and maintained the necessary module parameters (SAPRelease, SourceJRA, TargetDestination) in Sender File Adapter.
Now the file is not been picked by file adapter upon checking the Comm Channel Monitoring below error:
MP: exception caught with cause java.lang.StringIndexOutOfBoundsException: String index out of range -1
Any help would be highly appreciated.
Thanks in advanceHi Ramani,
I hope you must have found a solution on this, if not then kindly consider changing your source files, as this error corresponds to only one thing: i.e. DATA Issue. You need to correct the data which you providing to the module for conversion.
I faced this problem and corrected it by just correcting my test file.
Regards,
Nipun Shedhani -
FTP Sender Channel error " java.lang.StringIndexOutOfBoundsException""
Dear All,
Scenario:File to IDOC
File Type: Fixed Length
I am getting below error in Sender Channel.
Error "Conversion of file content to XML failed at position 0: java.lang.Exception: ERROR converting document line no. 2 according to structure 'Item':java.lang.StringIndexOutOfBoundsException"
Note:We are using header and Item.Header is not repating and Item should repeate N times.we are using the KeyField Name for both header and Item.
Kindly suggest me the Parameter to use for the sender channel.
Edited by: manikandansit on Jan 17, 2011 12:53 PMDear All,
Thanks for your suggestions.
the issues has been resolved.
there are so many spaces between the each field data in the source file and i was using the value as SPACE for the parameter Name.fieldSeparator and it taken each space as a data or something else. finally i had removed this parameter and Interfaces works fine now.
Thanks -
Does callableStatement.SetNull() work fine with ojdbc5.jar in oracle 11gr2
Hello,
CallableStatement.setNull(1, Types.ARRAY) throws java.sql.SQLException: Invalid column type: sqlType=2003
and
CallableStatement.setNull(1, Types.ARRAY, "SOMEARRAYTYPE") throws java.sql.SQLException: ORA-06531: Reference to uninitialized collection
ORA-06512: at "SYSTEM.SOMEARRAYTYPE", line 6
ORA-06512: at line 1
Is this a problem with the driver? Is there any other way of setting null value for a parameter of ARRAY type?
Thanks.user8915609 wrote:
But setNull(..) itself means that we are setting a null value. doesn't it?I dunno.. what does the Java docs say?
I am using setNull(..) instead of setObject(..) because i want to set a null value for an array parameter of the stored procedure.Well, that does not seem to be working, does it? So it is reasonable to assume that your are not correctly using/understanding what the setNull() call does.
For example (following on from the sample code I posted above), it depends on what one attempts to set to null in a collection:
SQL> declare
2 variable TStrings;
3 begin
4 --// a variable can be null
5 variable := null;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL>
SQL> declare
2 variable TStrings;
3 begin
4 --// a collection item cannot be null if the
5 --// collection itself has not been instantiated
6 variable(1) := null;
7 end;
8 /
declare
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 6
SQL>
SQL> declare
2 variable TStrings;
3 begin
4 --// instantiate with 2 items/strings in the collection
5 variable := new TStrings('1','2');
6
7 --// now we can set an existing item to null
8 variable(1) := null;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> If you code a command in ANY language, then you need to know EXACTLY what the command does, and why you are using it.
If not - then it is a fail on your part. -
JDBC - CallableStatement - Error in Accessing Stored Procedure of MS SQL
Dear Friends,
The following is the code to access a stored procedure of MS SQL Server 7.0 sp4,
try
CallableStatement cstmt;
ResultSet rst;
cstmt = connection.prepareCall("{call backupdb[?,?]}");
cstmt.setString("db_name","SBIREMITLIVE");
cstmt.setString("path", "c:\testing.bak");
cstmt.executeQuery();
System.out.println("Stored Procedure called successfully");
catch(SQLException se)
System.out.println(se.toString());
when i execute this i am getting the error as " MS ODBC-MS SQL Server Syntax error or Access Violation "
What's the problem exactly ? anybody came across this issue..if so...kindly help me....
Here is my MS SQL Server stored procedure.....for reference
create procedure backupdb(@db_name varchar(40), @path varchar(100)) as
Backup database @db_name to disk = @path
Regards,
V.PrasannaDear DigitalDreamer,
Yes, as per your suggestion, it's working fine...thanks a lot...
here is the code...
CallableStatement cstmt;
ResultSet rst;
cstmt = connection.prepareCall(" exec backupdb ?,? ");
cstmt.setString(1,"SBIREMITLIVE");
cstmt.setString(2, "c:\\testing.bak");
cstmt.execute();
Regards,
V.Prasanna -
Hi Guys
I am having some problem as I am using a DataSource for connections and randomly
the CallableStatements and PreparedStatements created from this DataSource becomes
null and everytime I get NullPointerException with this message.
java.sql.SQLException: java.lang.NullPointerException
at weblogic.jdbc.rmi.SerialPreparedStatement.setString(SerialPreparedStatement.java:210)
at .........
Help will be appreciated..Hi Guys
I am having some problem as I am using a DataSource for connections and randomly
the CallableStatements and PreparedStatements created from this DataSource becomes
null and everytime I get NullPointerException with this message.
java.sql.SQLException: java.lang.NullPointerException
at weblogic.jdbc.rmi.SerialPreparedStatement.setString(SerialPreparedStatement.java:210)
at .........
Help will be appreciated.. -
StringIndexOutOfBoundsException from Mail Adapter
Hi,
We have configured a sender communication channel for the mail adapter, but when we receive an email we get the following error message:
<i>error occured: exception caught during processing mail message; java.lang.StringIndexOutOfBoundsException: String index out of range: -1</i>
Our configuration is the following:
Transport Protocol: IMAP4
Message protocol: (tried both)
URL: imap://exchangeServerHost
The emails we tested with are plain/text emails. We tried both with an XML document as the main body of the email and with the XML document as an attachment, but the error remains the same.
If anyone has some ideas on how to resolve or troubleshoot this it would be appreciated.
Thanks in advance,
Erik.Thanks Ranjit...I fixed the error. It was the URL I was missing the inbox from the URL.
Check the following thread:
Email Adapter Throwing Error
Message was edited by:
Alaa Qasem
Maybe you are looking for
-
Please document what happens with INSERT...LOG ERRORS INTO + ROLLBACK
I posted this question on AskTom at and Tom suggested I open an iTar. However, I'm on XE, so that route is not open to me. So, for what it's worth, I'm making a request here in the hope that Oracle will do something about it, even though it's not an
-
hey guys, Looking to do a keypad in as3. So i have 10 numeric buttons, labelled num1-num10. I have a dynamic textbox that I'll show my presses. How do you record button clicks or keyboard presses of a certain number and display in the text box?
-
Yosemite and Photoshop (CS5.1) Problem
I recently updated to Yosemite and now Photoshop (CS5.1) won't open and I get an error message: An unexpected and unrecoverable problem has occurred. Photoshop will now exit. Has anyone else had this problem or know of a solution?
-
Hi, 11.2.0.1 When you db encounters "archive log full waiting to be freed", is there a way to resolve it without shutting down the db? Thanks. vk82 Oct 9, 2013 9:35 AM In case if your DB is Production. How will you continue to operate your DB in no a
-
Example: My wife views her e-mails every night. A lot of her e-mails are about recipes & stores with special offers. The next morning all the sites that she visited are in the "Most Visited". This also happens to me. I get tired of removing these sit