捕获到 IO 例外
错误信息:
建立conn出错:java.sql.SQLException: JZ006: 捕获到 IO 例外:java.net.ConnectException: Connection refused: connect
代码:
Driver driver = null;
Connection conn = null;
String DRIVER = "";
String _URL = "";
String USERNAME = "";
String PASSWORD = "";
Properties props = new Properties();
//public String serverInfo = "D:/Program Files/Apache Software "
//+ "Foundation/Tomcat 5.5/webapps/FlexDemo/params.ini";
// public String serverInfo = "/usr/tomcat/webapps/repo/params.ini";
public Connection getCon() {
try {
//File f = new File(serverInfo);
// System.out.print(System.);
//FileInputStream is = new FileInputStream(f);
//props.load(is);
DRIVER = props.getProperty("DRIVER",
"com.sybase.jdbc3.jdbc.SybDataSource");
_URL = props.getProperty("URL", "jdbc:sybase:Tds:10.34.1.19:4100/Kustom?charset=eucgb");
USERNAME = props.getProperty("USERNAME", "sa");
PASSWORD = props.getProperty("PASSWORD", "frodo12");
driver = (Driver) Class.forName(DRIVER).newInstance();
DriverManager.registerDriver(driver);
conn = DriverManager.getConnection(_URL, USERNAME, PASSWORD);
} catch (Exception e) {
System.out.println("建立conn出错:" + e);
}
return conn;
}
[解决办法]
连接被拒绝,你的用户名或密码不对吧
[解决办法]
用户名和密码是对的,刚才再次成功登录了数据库
[解决办法]
输出一下
e.printStackTrace();
现在哪行出问题都不知道了
[解决办法]
这是,数据库的连接被关闭导致的,