Java实现Sybase数据库连接
需要的jar包:jconn4.jar;
Java代码:
/** * @Title: getConnSybase * @Description: * @param * @return * @return Connection * @throws */ public static Connection getConnSybase() { try { Connection conn; InputStream path =Thread.currentThread().getContextClassLoader().getResourceAsStream("analysis.properties"); config.clear(); config.load(path); String url = config.getProperty("jdbc.url").toString(); String username = config.getProperty("jdbc.username").toString(); String password = config.getProperty("jdbc.password").toString(); String drvier = config.getProperty("jdbc.driver").toString(); Class.forName(drvier).newInstance(); conn = DriverManager.getConnection(url,username,password); return conn; } catch (Exception e) { return null; } }
配置文件信息:
#jdbc infomation jdbc.driver=com.sybase.jdbc4.jdbc.SybDriver jdbc.url= jdbc:sybase:Tds:192.58.100.124:2698/sybaseiq_xyzq_195 jdbc.username=admin jdbc.password=123456
注意:驱动的版本jar要与配置文件中的驱动版本一致;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/16827.html