Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 数据库值复制问题
flyingqifei

电脑为家 网络为舍



发贴: 35
积分: 0
于 2006-09-15 15:49 user profilesend a private message to usersend email to flyingqifeisearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
怎么把表1的某一字段值(image类型)复制到表2的某一字段(image类型)里?SQL语句怎么写?请教数据库高手.
如果这样不行,那怎么在程序中实现,先读出table1那个字段的值,然后再插入到table2中,一般的数据可以,image类型的怎么做的?我是这样做的,数据添加不成功.

java.io.InputStream filedata = null;
... ...
if (rs.next()) {
... ...
filedata = rs.getBinaryStream("FILEDATA");
... ...
}

String strSql = "update table2 set filedata=? where id=?";

PreparedStatement ps = dataConn.getConnection().prepareStatement(strSql);

ps.setBinaryStream(1,filedata,filedata.available());
ps.setInt(1,1);
... ...




My website: http://flyingqifei.icpcn.com
My BLOG: http://qifei.blogbus.com
作者 Re:数据库值复制问题 [Re:flyingqifei]
flyingqifei

电脑为家 网络为舍



发贴: 35
积分: 0
于 2006-09-15 18:01 user profilesend a private message to usersend email to flyingqifeisearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
SQL语句在数据库查询分析器里可以用,程序里不行,提示不支持text,ntext,image类型.在程序里用以上代码插入的值不正确.


My website: http://flyingqifei.icpcn.com
My BLOG: http://qifei.blogbus.com
作者 Re:数据库值复制问题 [Re:flyingqifei]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-09-15 18:55 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
which DB server?
which JDBC driver?
...



作者 Re:数据库值复制问题 [Re:flyingqifei]
flyingqifei

电脑为家 网络为舍



发贴: 35
积分: 0
于 2006-09-18 09:24 user profilesend a private message to usersend email to flyingqifeisearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我用的SQLServer2000,JDBC版本不知道,应该比较老了,修改时间是2002.04的,新版本支持image类型的吗?我下载一个试试


My website: http://flyingqifei.icpcn.com
My BLOG: http://qifei.blogbus.com
作者 Re:数据库值复制问题 [Re:flyingqifei]
flyingqifei

电脑为家 网络为舍



发贴: 35
积分: 0
于 2006-09-18 11:18 user profilesend a private message to usersend email to flyingqifeisearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好不容易下个for SP3的JDBC,还是提示:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]在这一子查询或聚合表达式中,text、ntext 和 image 数据类型无效。
看样子JDBC不支持的。
我的查询语句是update indollar_DAGD set filedata=(select filedata from indollar_gwxx where gwid=?) where gdid=?

我还是想用楼顶上的那种方法传递,但是复制过去的数据值不对,值只有Ox,相当于空值了。不知道怎么把这种类型通过输入输出流来传递。



My website: http://flyingqifei.icpcn.com
My BLOG: http://qifei.blogbus.com
作者 Re:数据库值复制问题 [Re:flyingqifei]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-09-18 15:58 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
try jTDS or the latest version of SQL Server JDBC driver
http://jtds.sourceforge.net/
http://msdn.microsoft.com/data/ref/jdbc/ (SQL Server 2005 JDBC Driver 1.1)



作者 Re:数据库值复制问题 [Re:flyingqifei]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2006-09-18 20:19 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
sqlserver二○○○ 不是有个 DTS 吗!


"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"


flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923