知道美河 | 上传资料 | VIP申请 | 精品课程 | 资料搜索 | 问题反馈 | 会员手册 | 积分消费 | 积分充值 | 帐号保护
美河学习学习在线赞助VIP

美河学习在线(主站) eimhe.com

 找回密码
 建立账号
查看: 3229|回复: 1

[求助] 以下java程序有什么错误呢?

[复制链接]
发表于 2008-3-1 11:25:36 | 显示全部楼层 |阅读模式
import java.sql.*;
public class MSSQLText
{
public static void main(String args[]) throws SQLException
{
String str="select * from USER_FILES";
Connection con = null;
//PreparedStatement pre = null;
ResultSet rs = null;

try {

        System.out.println("开始建立连接");
        con = getConnectionL();
        System.out.println("已经建立连接");
//        pre = con.prepareStatement(str,
//                        ResultSet.TYPE_SCROLL_INSENSITIVE,
//                        ResultSet.CONCUR_UPDATABLE);
//        System.out.println("执行!");

rs=((Statement) con).executeQuery(str);


while(rs.next())
{
System.out.println(rs.getString("Name")+" ");
}
rs.close();
con.close();
}
catch(Exception err){
err.printStackTrace(System.out);
}
}


public static Connection getConnectionL() {
        String strDriver = "com.sybase.jdbc.SybDriver";
        Connection conn = null;
        String url = "jdbc:sybase:Tds:localhost:4100/DBNAME?charset=eucgb";

        try {
                Class.forName(strDriver).newInstance();
        } catch (Exception e) {
                System.out.println(e.getMessage() + "driver");
                }
        try {
                conn = DriverManager.getConnection(url, "sa", "111111");
        } catch (Exception e) {
                System.out.println(e.getMessage() + "driver");
        }

        return conn;
}

}
 楼主| 发表于 2008-3-1 14:41:51 | 显示全部楼层
您需要登录后才可以回帖 登录 | 建立账号

本版积分规则

 
QQ在线咨询

QQ|小黑屋|手机版|Archiver|美河学习在线 ( 浙网备33020302000026号 )

GMT+8, 2025-5-3 22:41

Powered by Discuz!

© 2001-2025 eimhe.com.

快速回复 返回顶部 返回列表