linux导出sqlserver数据,从 window上的 SqlServer导出数据到 linux 上的Sybase

PreparedStatement pssy=null;

Connection connsy=null;

ResultSet rssy=null;

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

String urlsq="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=lyweb";

String usersq="sa";

String passwordsq="sa";

Connection connsq= DriverManager.getConnection(urlsq,usersq,passwordsq);

Class.forName("com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource").newInstance();

String urlsy="jdbc:sybase:Tds:10.165.0.65:4100/webdb";

String usersy="sa";

String passwordsy="sa";

connsy= DriverManager.getConnection(urlsy,usersy,passwordsy);

PreparedStatement pssq=null;

ResultSet rssq=null;

pssq=connsq.prepareStatement("select * from office");

rssq=pssq.executeQuery();

while(rssq.next())

{

String departid=rssq.getString("departid");

String departname = rssq.getString("departname");

if(departname==null)

departname="";

String postcord = rssq.getString("postcord");

if(postcord==null)

postcord="";

String address=rssq.getString("address");

if(address==null)

address="";

String tel = rssq.getString("tel");

if(tel==null)

tel="";

String leader = rssq.getString("leader");

if(leader==null)

leader="";

String departdescript=rssq.getString("departdescript");

if(departdescript==null)

departdescript="";

String parentid = rssq.getString("parentid");

if(parentid==null)

parentid="000";

pssy=connsy.prepareStatement("insert into office (departid,departname,postcord,address,tel,leader,departdescript,parentid) values(?,?,?,?,?,?,?,?)");

pssy.setString(1,new String(departid.getBytes("gb2312"),"ISO8859_1"));//新闻ID

pssy.setString(2,new String(departname.getBytes("gb2312"),"ISO8859_1"));//栏目ID

pssy.setString(3,new String(postcord.getBytes("gb2312"),"ISO8859_1"));//标题

pssy.setString(4,new String(address.getBytes("gb2312"),"ISO8859_1"));//副标题

pssy.setString(5,new String(tel.getBytes("gb2312"),"ISO8859_1"));//内容

pssy.setString(6,new String(leader.getBytes("gb2312"),"ISO8859_1"));//浏览量

pssy.setString(7,new String(departdescript.getBytes("gb2312"),"ISO8859_1"));//作者

pssy.setString(8,new String(parentid.getBytes("gb2312"),"ISO8859_1"));//发布者用户名

try

{

pssy.executeUpdate();

}

catch(Throwable t)

{

pssy=connsy.prepareStatement("update office set departname=?,postcord=?,address=?,tel=?,leader=?,departdescript=?,parentid=? where departid=?");

pssy.setString(1,new String(departname.getBytes("gb2312"),"ISO8859_1"));//栏目ID

pssy.setString(2,new String(postcord.getBytes("gb2312"),"ISO8859_1"));//标题

pssy.setString(3,new String(address.getBytes("gb2312"),"ISO8859_1"));//副标题

pssy.setString(4,new String(tel.getBytes("gb2312"),"ISO8859_1"));//内容

pssy.setString(5,new String(leader.getBytes("gb2312"),"ISO8859_1"));//浏览量

pssy.setString(6,new String(departdescript.getBytes("gb2312"),"ISO8859_1"));//作者

pssy.setString(7,new String(parentid.getBytes("gb2312"),"ISO8859_1"));//发布者用户名

pssy.setString(8,new String(departid.getBytes("gb2312"),"ISO8859_1"));

out.println(departname);

//pssy.executeUpdate();

}

}

%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值