Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing an array of Strings to a stored procedure

843854May 23 2003 — edited Dec 28 2007
I am having trouble passing an array of Strings to a stored procedure. I was able to pass array ints but with Strings I am getting the following error:

java.sql.SQLException: Non supported character set: oracle-character-set-46

I appreciate any help regarding this. Please find the code below:
/****************************************************************/
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import oracle.jdbc.driver.OracleTypes;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class Test
{
//Database connection object...
private Connection dbCon;

public static void main(String[] args)
{
Test tst = new Test();

if(true == tst.getConnection())
{
tst.callSP();
}//End if(true == tst.getConnection())
}

public void callSP()
{
//System.out.println("Got database connection");
String outVal = "";
String arOFStrs[] = new String[5];
arOFStrs[0] = new String("ELEMENT1");
arOFStrs[1] = new String("ELEMENT2");
arOFStrs[2] = new String("ELEMENT3");
arOFStrs[3] = new String("ELEMENT4");
arOFStrs[4] = new String("ELEMENT5");

try
{
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("SRINITEST", dbCon);
ARRAY newArray = new ARRAY(desc, dbCon, arOFStrs);

CallableStatement call = dbCon.prepareCall("call PK_MIKES.SRINI(?, ?)");
call.setObject(1,newArray,OracleTypes.ARRAY);
//call.setString(2, outVal);
call.registerOutParameter(2, java.sql.Types.VARCHAR);
call.execute();

outVal = call.getString(2);

call.close();


System.out.println("Output from Procedure = <" + outVal + ">");
}
catch(SQLException sqlE)
{
System.out.println(
"SQLException : ");
System.out.println(sqlE.toString());
System.exit(0);
}

return;
}

public boolean getConnection()
{
boolean bRetVal = false;
String connectString = new String("jdbc:oracle:thin:@testDBSvr:1234:testdb");

//Then create the database connection...
try
{
//First register the Oracle Jdbc driver with the DriverManager...
DriverManager.registerDriver(
new oracle.jdbc.driver.OracleDriver());

//Then get the connection object from the DriverManager...
dbCon = DriverManager.getConnection(
connectString.trim(),
"scott",
"tiger");

if(null == dbCon)
{
System.out.println("Object dbCon is null");
}
else
{
System.out.println("Successfully created the database connection");
bRetVal = true;
}
}
catch(SQLException e)
{
System.out.println(
"SQLException while creating a Database Connection");
System.out.println(e.toString());
System.exit(0);
}

return(bRetVal);

}//End of init()

}

/****************************************************************/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 25 2008
Added on May 23 2003
4 comments
455 views