为什么数据库有时连得上,有时连不上

ye_zhy 2002-02-04 05:52:12
为什么我的程序在连数据库时有时能连得上,有时就连不上
import java.util.*;
import java.sql.*;
import com.sybase.jdbc2.jdbc.*;
public class DBConn {
Connection c=null;
private static String user = null;
private static String password = null;
private static String owner = null;
private static String dburl = null;
private static String dbdriver = null;
private String cfgFileName = "DBConn";
pulic Connection getConnect() {
try{
PropertyResourceBundle configBundle = (PropertyResourceBundle)PropertyResourceBundle.getBundle(cfgFileName );
user = configBundle.getString("db.user");
password = configBundle.getString("db.password");
owner = configBundle.getString("db.owner");
dburl = configBundle.getString("db.dburl");
dbdriver = configBundle.getString("db.dbdriver");
Class.forName(dbdriver);
return DriverManager.getConnection(dburl,user,password);
}
catch(Exception e){}
}
...全文
211 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
DragonFly-9 2002-02-07
  • 打赏
  • 举报
回复
年底给分了
xuxb488 2002-02-06
  • 打赏
  • 举报
回复
upup^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DragonFly-9 2002-02-05
  • 打赏
  • 举报
回复
我用来连接unix Sybase的一段代码你参考一下:
Connection getConnect(String host,String usrname,String pwds)
{
String dbUrlStr = "jdbc:sybase:Tds:" + host;//host="192.168.0.240:5000/callcenter"
try{
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
return DriverManager.getConnection(dbUrlStr,usrname,pwds);
}catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
shpblk 2002-02-05
  • 打赏
  • 举报
回复
Class.forName("com.sybase.jdbc2.jdbc....")
bbc218888 2002-02-05
  • 打赏
  • 举报
回复
ppooiuuyuy
bbc218888 2002-02-05
  • 打赏
  • 举报
回复
ipuuippupupu
ye_zhy 2002-02-04
  • 打赏
  • 举报
回复
错误里输出的是“连接已关闭“
meixiaolong 2002-02-04
  • 打赏
  • 举报
回复
你在catch(Exception)){"这里输入一些代码查看错误"}

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧