正在加载图片...
简单的 Connection工具类别 public class simple DB SourceimplementsDBSource public simpleDB Source(string configFile) throws IOException ClassNotFoundException props new Properties( props. load(new FileInputstream (configfile)) rl props getProperty( onlyfun caterpillarurl )i user props getProperty ( onlyfun caterpillar user passwd props. getProperty("onlyfun caterpillar password")i Class. forName props. getProperty ("onlyfun caterpillar driver ))i public Connection getConnection() throws SQLException return DriverManager getConnection(url, user, passwd)i public void closeConnection(Connection conn) throws SQLException t conn close()i简单的Connection工具类别 public class SimpleDBSourceimplementsDBSource { … public SimpleDBSource(String configFile) throws IOException, ClassNotFoundException { props = new Properties(); props.load(new FileInputStream(configFile)); url = props.getProperty("onlyfun.caterpillar.url"); user = props.getProperty("onlyfun.caterpillar.user"); passwd = props.getProperty("onlyfun.caterpillar.password"); Class.forName( props.getProperty("onlyfun.caterpillar.driver")); } public Connection getConnection() throws SQLException { return DriverManager.getConnection(url, user, passwd); } public void closeConnection(Connection conn) throws SQLException { conn.close(); } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有