[英]JDBC Clob and NClob
Is there any difference between java.sql.Clob
and java.sql.NClob
? java.sql.Clob
和java.sql.NClob
有什么区别? There is no new method for java.sql.NClob
interface. java.sql.NClob
接口没有新方法。 I tried the following: 我尝试了以下方法:
The setup SQL: 设置SQL:
create table tab(id number(2), clobcol clob, nclobcol nclob)
insert into tab values (1, to_clob('你好'), to_nclob('你好'))
JDBC code: JDBC代码:
conn = getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from tab");
rs.next();
Clob c = rs.getClob(2);
NClob nc = rs.getNClob(3);
InputStream inputStream1 = c.getAsciiStream();
InputStream inputStream2 = nc.getAsciiStream();
System.out.println(inputStream1.available());
System.out.println(inputStream2.available());
c.free();
nc.free();
I have also tried some other methods, looks like there is no difference from the output. 我还尝试了其他一些方法,看起来与输出没有区别。 Is there a specific I can see some differences ?
我能看到一些具体的区别吗?
Added the supported character set in the database: 在数据库中添加了受支持的字符集:
SELECT parameter, value
FROM v$nls_parameters
3 WHERE parameter LIKE '%CHARACTERSET';
PARAMETER VALUE
--------------------------------- --------------------
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16
In the old days (80s) many Databases were created using US7ASCII (in the US) or ISOLATIN1 (in Europe) as the character set. 在过去(80年代),使用US7ASCII(在美国)或ISOLATIN1(在欧洲)作为字符集创建了许多数据库。 For these Databases that still exist today (after many upgrades), the only way to store non-ASCII character String data is to use the special types NVARCHAR or NCLOB.
对于今天仍然存在(经过多次升级)的这些数据库,存储非ASCII字符串数据的唯一方法是使用特殊类型的NVARCHAR或NCLOB。 These Nxxx types are not used by newer Databases that were created directly using UTF8 (now the default in Oracle) as the encoding.
使用UTF8(现在是Oracle中的默认值)作为编码直接创建的较新数据库不使用这些Nxxx类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.