oracle jdbc字符设置
写全了
CREATE TYPE num_varray AS VARRAY(10) OF VARCHAR2(12)
/
CREATE TABLE varray_table (col1 num_varray);
INSERT INTO varray_table VALUES (num_varray( '你好 ', 'abc '));
select * from varray_table;
*/
import java.sql.*;
import java.math.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
class Array1
{
public static void main(String args[]) throws Exception
{
int oracleId = CharacterSet.ZHS16GBK_CHARSET;
CharacterSet dbCharset = CharacterSet.make(oracleId);
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection
( "jdbc:oracle:thin:@10.9.200.58:1521:db01 ",
"mytest ",
"mytest ");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery( "SELECT * FROM varray_table ");
while (rs.next()) {
ARRAY my_array = ((OracleResultSet)rs).getARRAY(1);
// return the SQL type names, integer codes,
// and lengths of the columns
System.out.println ( "Array is of type " + my_array.getSQLTypeName());
System.out.println ( "Array element is of typecode " + my_array.getBaseType());
System.out.println ( "Array is of length " + my_array.length());
// get Array elements
&nb
相关新闻>>
- 发表评论
-
- 最新评论 更多>>