DBLink创建方法
来源:互联网 发布:药学知乎 编辑:程序博客网 时间:2024/05/21 02:22
DBLink创建方法
create database link dblinkName connect to touser identified by "password" using '在本地配置的链接'
使用
select * from tableName@dblinkName;
create table tableName as select * from tableName@dblinkName;可以将远程的数据导入到现有数据库。
Blob使用:
public static int insertBlob(String filepath){
int i = 0;
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
//通过JDBC获得数据库连接
conn = DBConnection.getConnection();
//设置数据库为不自动提交,必须的一步
conn.setAutoCommit(false);
st = conn.createStatement();
//插入一个空对象empty_blob()
String insertSql = "insert into MOF_DOC_BLOB (ID, FILEPATH, CONTENT) values (1,'"+filepath+"', empty_blob())";
i = st.executeUpdate(insertSql);
String selectSql = "select CONTENT from MOF_DOC_BLOB where ID=1 for update";
rs = st.executeQuery(selectSql);
if (rs.next()) {
//得到流
oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob(1);
//从得到的低级流构造一个高级流
PrintStream ps = new PrintStream(blob.getBinaryOutputStream());
BufferedInputStream bis;
try {
bis = new BufferedInputStream(new FileInputStream(filepath));
byte[] buff = new byte[1024];
int n = 0;
//从输入到输出
while ((n = bis.read(buff)) != -1) {
ps.write(buff, 0, n);
}
//清空流的缓存
ps.flush();
//关闭流,注意一定要关
ps.close();
bis.close();
} catch (FileNotFoundException e) {
System.out.println("Util.java================>insert BLOB file not fonud");
return 1;
} catch (IOException e) {
System.out.println("Util.java================>insert BLOB error");
return 1;
}
}
return i;
} catch (SQLException e) {
e.printStackTrace();
System.out.println("get conn error!");
return 1;
}finally {
try {
if(rs != null){
rs.close();
}
if(st !=null){
st.close();
}
if (conn != null) {
conn.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
- DBLink创建方法
- 创建 DBLink 的方法
- 创建dblink的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- Oracle 创建 DBLink 的方法
- oracle 中 dblink 的创建方法
- oracle中dblink的创建方法
- oracle 中 dblink 的创建方法
- PBOC2.0 脱机数据认证SDA和DDA
- spring数据源配置
- 用户控件和href,src及其css路径问题
- Create PVR texture from png file
- 各种浏览器的cache文件夹
- DBLink创建方法
- web messaging
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)
- 常用的android intent和intent action
- c#asp.net 读取 写入 txt 文件 asp.net操作文件
- 理解和使用C++中的智能指针
- 想要清晨不赖床?11个超实用妙招!
- vs2005 timer控件的interval值最大到底是多少?
- 友情链接交换三要素:让网站细水长流