Debugging notes for solving Oracle array Character Set problems.

Source: Internet
Author: User

Import java. SQL. callablestatement;
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. resultset;
Import java. SQL. sqlexception;
Import java. util. arraylist;
Import java. util. List;

Import oracle. JDBC. oracletypes;
Import oracle. JDBC. rowset. oraclecachedrowset;
Import oracle. SQL. array;
Import oracle. SQL. arraydescriptor;
Import oracle. SQL. characterset;

Public class temp {

/**
* @ Param ARGs
*/
Public static void main (string [] ARGs) throws exception {

Class. forname ("oracle. JDBC. Driver. oracledriver ");
Connection conn = drivermanager. getconnection ("JDBC: oracle: thin: @ XXXXXXXX: 1521: billbj1", "XXXX", "XXXX ");
Callablestatement = conn. preparecall ("{? = Call xxxxxxxxxxxxx (?,?,?,?)} ");
Callablestatement. registeroutparameter (1, oracletypes. cursor );

 

Characterset dbcharset = characterset. Make (characterset. al32utf8_charset); // you can specify the character set for debugging.

List <oracle. SQL. Char> cid = new arraylist <oracle. SQL. Char> ();
Oracle. SQL. Char value = new Oracle. SQL. Char ("6487", dbcharset );
CID. Add (value );

List <oracle. SQL. Char> nid = new arraylist <oracle. SQL. Char> ();
Value = new Oracle. SQL. Char ("0105591", dbcharset );
Nid. Add (value );

Array channelidarray = createarray ("channelidarray", CID, Conn );
Callablestatement. setarray (2, channelidarray );
Callablestatement. setstring (3, "200810010000 ");
Callablestatement. setstring (4, "200810010059 ");
Array nodeidarray = createarray ("nodeidarray", NID, Conn );
Callablestatement. setarray (5, nodeidarray );
Callablestatement.exe cute ();

resultset RS1 = (resultset) callablestatement. getObject (1);
oraclecachedrowset rs = new oraclecachedrowset ();
Rs. populate (RS1);
rs1.close ();
callablestatement. close ();
Conn. close ();
int x = 0;
while (RS. next () & ++ x <10) {
JAVA. SQL. timestamp d = Rs. gettimestamp (1);

system. out. println (D. tostring ();
}< BR >}< br> Private Static array createarray (final string sqltypename,
final list channelids, connection)
throws sqlexception {
arraydescriptor channelidarraydesc = arraydescriptor. createdescriptor (
sqltypename, connection);
array channelidarray = new array (channelidarraydesc, connection, channelids. toarray (New Oracle. SQL. char [0]);
return channelidarray;
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.