oracle

推荐列表 站点导航

当前位置:首页 > 数据库 > oracle >

oracle中读写blob字段的问题解析

来源:网络整理  作者:网络  发布时间:2020-12-10 23:30
这篇文章以程序实例说明通过JDBC操纵Oracle数据库LOB类型字段的几种情况...
}

out.write(c);

/* 恢复原提交状态 */
BufferedReader in = new BufferedReader(new FileReader(infile));

/* 恢复原提交状态 */
public static void clobRead(String outfile) throws Exception
conn.rollback();
out.write(c);
CREATE TABLE TEST_BLOB ( ID NUMBER(3), BLOBCOL BLOB)

out.close();
conn.commit();
/* 取出此CLOB对像 */
out.close();
/* 设定不自动提交 */
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
}

try {

}
{
BufferedReader in = new BufferedReader(clob.getCharacterStream());


in.close();
BufferedReader in = new BufferedReader(new FileReader(infile));
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
{
stmt.executeUpdate("INSERT INTO TEST_CLOB VALUES ('111', EMPTY_CLOB())");
/* 以字符形式输出 */
boolean defaultCommit = conn.getAutoCommit();
/* 正式提交 */
in.close();
conn.setAutoCommit(defaultCommit);
BufferedWriter out = new BufferedWriter(new FileWriter(outfile));

LOB类型分为BLOB和CLOB两种:BLOB即二进制大型对像(Binary Large Object),适用于存贮非文本的字节流数据(如程序、图像、影音等)。而CLOB,即字符型大型对像(Character Large Object),则与字符集相关,适于存贮文本型的数据(如歷史档案、大部头著作等)。
ResultSet rs = stmt.executeQuery("SELECT * FROM TEST_CLOB WHERE");
while ((c=in.read())!=-1) {
conn.commit();
/* 出错回滚 */
out.write(c);
while ((c=in.read())!=-1) {
public static void clobModify(String infile) throws Exception

复制代码 代码如下:

/* 向CLOB对像中写入数据 */
下面以程序实例说明通过JDBC操纵Oracle数据库LOB类型字段的几种情况。

}

} catch (Exception ex) {
}
stmt.executeUpdate("UPDATE TEST_CLOB SET CLOBCOL=EMPTY_CLOB() WHERE");
while ((c=in.read())!=-1) {
in.close();
conn.setAutoCommit(defaultCommit);
int c;
int c;
conn.setAutoCommit(false);

conn.setAutoCommit(defaultCommit);

/* 获取此CLOB对像 */
while (rs.next()) {

复制代码 代码如下:


}
conn.setAutoCommit(defaultCommit);
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
/* 设定不自动提交 */

1、 向数据库中插入一个新的BLOB对像

/* 查询CLOB对象并锁定 */
}

try {
} catch (Exception ex) {
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
public static void clobReplace(String infile) throws Exception
conn.rollback();

}

/* 查询CLOB对象并锁定 */


/* 恢复原提交状态 */
}
in.close();
boolean defaultCommit = conn.getAutoCommit();
int c;

二、 BLOB对象的存取

ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");

3、替换CLOB对像(将原CLOB对像清除,换成一个全新的CLOB对像)

/* 查询此CLOB对象并锁定 */
/* 获取此CLOB对像 */
/* 清空原CLOB对像 */
conn.rollback();

复制代码 代码如下:

/* 正式提交 */

try {
/* 进行覆盖式修改 */
/* 设定不自动提交 */
}

boolean defaultCommit = conn.getAutoCommit();

一、 CLOB对象的存取

复制代码 代码如下:

conn.setAutoCommit(false);

/* 查询CLOB对像 */

复制代码 代码如下:

while (rs.next()) {
/* 出错回滚 */
throw ex;
}
}
CREATE TABLE TEST_CLOB ( ID NUMBER(3), CLOBCOL CLOB)
conn.setAutoCommit(false);


} catch (Exception ex) {
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
/* 正式提交 */
while (rs.next()) {
boolean defaultCommit = conn.getAutoCommit();
}
}
/* 更新数据 */
ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");
out.close();
}
} catch (Exception ex) {

try {
}
conn.commit();
out.close();
throw ex;
/* 出错回滚 */

conn.setAutoCommit(false);

{

4、CLOB对像读取

oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
conn.rollback();
while ((c=in.read())!=-1) {

2、修改CLOB对像(是在原CLOB对像基础上进行覆盖式的修改)

throw ex;
{
while (rs.next()) {

/* 恢复原提交状态 */
out.write(c);

public static void clobInsert(String infile) throws Exception

先建立如下两个测试用的数据库表,Power Designer PD模型如下:

/* 获取CLOB对像 */
ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");
/* 插入一个空的CLOB对像 */
BufferedReader in = new BufferedReader(new FileReader(infile));
throw ex;

int c;

1、往数据库中插入一个新的CLOB对像

/* 设定不自动提交 */

建表SQL语句为:

相关热词: oracle 解析

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/sql/oracle/2348.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

oracle中读写blob字段的问题解析

2020-12-10 编辑:网络

}

out.write(c);

/* 恢复原提交状态 */
BufferedReader in = new BufferedReader(new FileReader(infile));

/* 恢复原提交状态 */
public static void clobRead(String outfile) throws Exception
conn.rollback();
out.write(c);
CREATE TABLE TEST_BLOB ( ID NUMBER(3), BLOBCOL BLOB)

out.close();
conn.commit();
/* 取出此CLOB对像 */
out.close();
/* 设定不自动提交 */
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
}

try {

}
{
BufferedReader in = new BufferedReader(clob.getCharacterStream());


in.close();
BufferedReader in = new BufferedReader(new FileReader(infile));
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
{
stmt.executeUpdate("INSERT INTO TEST_CLOB VALUES ('111', EMPTY_CLOB())");
/* 以字符形式输出 */
boolean defaultCommit = conn.getAutoCommit();
/* 正式提交 */
in.close();
conn.setAutoCommit(defaultCommit);
BufferedWriter out = new BufferedWriter(new FileWriter(outfile));

LOB类型分为BLOB和CLOB两种:BLOB即二进制大型对像(Binary Large Object),适用于存贮非文本的字节流数据(如程序、图像、影音等)。而CLOB,即字符型大型对像(Character Large Object),则与字符集相关,适于存贮文本型的数据(如歷史档案、大部头著作等)。
ResultSet rs = stmt.executeQuery("SELECT * FROM TEST_CLOB WHERE");
while ((c=in.read())!=-1) {
conn.commit();
/* 出错回滚 */
out.write(c);
while ((c=in.read())!=-1) {
public static void clobModify(String infile) throws Exception

复制代码 代码如下:

/* 向CLOB对像中写入数据 */
下面以程序实例说明通过JDBC操纵Oracle数据库LOB类型字段的几种情况。

}

} catch (Exception ex) {
}
stmt.executeUpdate("UPDATE TEST_CLOB SET CLOBCOL=EMPTY_CLOB() WHERE");
while ((c=in.read())!=-1) {
in.close();
conn.setAutoCommit(defaultCommit);
int c;
int c;
conn.setAutoCommit(false);

conn.setAutoCommit(defaultCommit);

/* 获取此CLOB对像 */
while (rs.next()) {

复制代码 代码如下:


}
conn.setAutoCommit(defaultCommit);
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
/* 设定不自动提交 */

1、 向数据库中插入一个新的BLOB对像

/* 查询CLOB对象并锁定 */
}

try {
} catch (Exception ex) {
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
public static void clobReplace(String infile) throws Exception
conn.rollback();

}

/* 查询CLOB对象并锁定 */


/* 恢复原提交状态 */
}
in.close();
boolean defaultCommit = conn.getAutoCommit();
int c;

二、 BLOB对象的存取

ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");

3、替换CLOB对像(将原CLOB对像清除,换成一个全新的CLOB对像)

/* 查询此CLOB对象并锁定 */
/* 获取此CLOB对像 */
/* 清空原CLOB对像 */
conn.rollback();

复制代码 代码如下:

/* 正式提交 */

try {
/* 进行覆盖式修改 */
/* 设定不自动提交 */
}

boolean defaultCommit = conn.getAutoCommit();

一、 CLOB对象的存取

复制代码 代码如下:

conn.setAutoCommit(false);

/* 查询CLOB对像 */

复制代码 代码如下:

while (rs.next()) {
/* 出错回滚 */
throw ex;
}
}
CREATE TABLE TEST_CLOB ( ID NUMBER(3), CLOBCOL CLOB)
conn.setAutoCommit(false);


} catch (Exception ex) {
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
/* 正式提交 */
while (rs.next()) {
boolean defaultCommit = conn.getAutoCommit();
}
}
/* 更新数据 */
ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");
out.close();
}
} catch (Exception ex) {

try {
}
conn.commit();
out.close();
throw ex;
/* 出错回滚 */

conn.setAutoCommit(false);

{

4、CLOB对像读取

oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
conn.rollback();
while ((c=in.read())!=-1) {

2、修改CLOB对像(是在原CLOB对像基础上进行覆盖式的修改)

throw ex;
{
while (rs.next()) {

/* 恢复原提交状态 */
out.write(c);

public static void clobInsert(String infile) throws Exception

先建立如下两个测试用的数据库表,Power Designer PD模型如下:

/* 获取CLOB对像 */
ResultSet rs = stmt.executeQuery("SELECT CLOBCOL FROM TEST_CLOB WHERE FOR UPDATE");
/* 插入一个空的CLOB对像 */
BufferedReader in = new BufferedReader(new FileReader(infile));
throw ex;

int c;

1、往数据库中插入一个新的CLOB对像

/* 设定不自动提交 */

建表SQL语句为:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/sql/oracle/2348.shtml

相关文章

风云图片

推荐阅读

返回oracle频道首页