错误信息:
建立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;
}
连接成功。
已尝试用此进行连接:
HOSTNAME=zhangbo_8104;SERVERNAME=helonglong;USER=sa;JCONNECT_VERSION=0;PASSWORD=***;<HOST>=zhangbo_8104;<PORT>=5000