返回首页

gbase数据、南大通用产品文档:GBase8c

更新日期:2024年09月11日

Thu Aus 9 16:46:38 CST 2022

GBA-01BR-0075
错误码
错误标识
错误显示信息
GBA-01BR-0075

init Ged_new_path table fail
错误出现原因
表恢复过程中,初始化表元数据信息失败

GBase 8s JDBC Driver 不会自动在 TEXT 、BYTE 、CLOB 和 BLOB 数据类型的代码集
之间进行转换。
可以使用以下方式在 TEXT 和 CLOB 数据类型的代码集之间进行转换:

可以通过使用 IFX_CODESETLOB 环境变量自动化客户端和数据库语言环境之间
的 TEXT 或 CLOB 数据的代码集转换。

可以使用 getBytes() 、
getString() 、
InputStreamReader() 和 OutputStreamWriter() 方法
在 TEXT 数据代码集之间进行转换。
使用 IFX_CODESETLOB 环境变量转换
可以自动转换 TEXT 和 CLOB 数据类型的代码集对:

在将数据发送到数据库服务器之前从客户端语言环境转换到数据库语言环境。

在客户端检索数据之前,从数据库语言环境转换到客户端语言环境。
要自动化 TEXT 和 CLOB 数据类型的代码集之间的转换,请在连接 URL 中使
用 IFX_CODESETLOB 环境变量。例如:IFX_CODESETLOB = 4096。还可以使用以
下 IfxDataSource 类的方法来设置和获取 IFX_CODESETLOB 值:

GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 227 -

public void setIfxIFX_CODESETLOB(int codesetlobFlag);
public int getIfxIFX_CODESETLOB();
IFX_CODESETLOB 可以具有以下值:
none
缺省值 不启用自动转换代码集。
0 在内部临时文件中发生自动转换代码集。
> 0 在客户端计算机的内存中发生自动转换代码集。该值指示分配给转换的字节数。

如果分配的字节数小于大对象的大小,则返回错误。
要在内存中执行转换,必须指定一个小于客户机的内存限制的量,并且大于任何已转换大
对象的可能大小。
当您使用以下 java.sql.Clob 接口方法或 Clob 接口的 GBase 8s 扩展中的任何一种时,即使
设置了 IFX_CODESETLOB 环境变量,也不会执行代码集转换。这些方法包括:
IfxCblob::setAsciiStream(long) Clob::setAsciiStream(long position, InputStream fin, int
length)
IFX_CODESETLOB 仅对来自 java.sql.PreparedStatement 接口的方法生效。
但是,在使用以下 java.sql.Clob 接口方法或 Clob 接口的 GBase 8s 扩展时,Unicode 字符
总是自动转换为数据库语言环境代码集。以下是这些方法的列表:
Clob::setCharacterStream(long) throws SQLException
Clob::setString(long, String) throws SQLException
Clob:: setString(long pos, String str, int offset, int len)
IfxCblob::setSubString(long position, String str, int length)
使用 JDK 方法转换
getBytes() 、getString() 、InputStreamReader() 和 OutputStreamWriter() 方法接受一个代码集
参数,该参数可以在 Unicode 与指定的代码集之间相互转换
以下样例代码显示了如何将客户端代码集中的文件转换为 Unicode,然后将其从 Unicode
转换为数据库代码集:
File infile = new File("data_jpn.dat");
File outfile = new File ("data_conv.dat");..
.pstmt = conn.prepareStatement("insert into t_text values (?)");..
.// Convert data from client encoding to database encoding
System.out.println("Converting data ...\n");
try
{
String from = "SJIS";

GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 228 -

String to = "8859_1";
convert(infile, outfile, from, to);
}
catch (Exception e)
{
System.out.println("Failed to convert file");
}

System.out.println("Inserting data ...\n");
try
{
int fileLength = (int) outfile.length();
fin = new FileInputStream(outfile);
pstmt.setAsciiStream(1 , fin, fileLength);
pstmt.executeUpdate();
}
catch (Exception e)
{
System.out.println("Failed to setAsciiStream");
}..
.public static void convert(File infile, File outfile, String from, String to)
throws IOException
{
InputStream in = new FileInputStream(infile);
OutputStream out = new FileOutputStream(outfile);

Reader r = new BufferedReader( new InputStreamReader( in, from));
Writer w = new BufferedWriter( new OutputStreamWriter( out, to));

//Copy characters from input to output. The InputStreamReader converts
// from the input encoding to Unicode, and the OutputStreamWriter
// converts from Unicode to the output encoding. Characters that can
// not be represented in the output encoding are output as '?'

char[] buffer = new char[4096];
int len;
while ((len = r.read(buffer)) != -1)

GBase 8s JDBC Driver 程序员指南
南大通用数据技术股份有限公司
- 229 -

w.write(buffer, 0, len);
r.close();
w.flush();
w.close();
}
当从数据库检索数据时,
可以使用相同的方法将数据从数据库代码集转换为客户端代码集。