package dao; import java.io.IOException; import java.io.InputStream; import java.sql.*; import java.util.Properties; public class BaseDao { private static String url; private static String username; private static String password; private static String driver; static{ Properties properties=new Properties(); InputStream is= BaseDao.class.getClassLoader().getResourceAsStream("db.properties"); try { properties.load(is); } catch (IOException e) { e.printStackTrace(); } driver=properties.getProperty("driver"); url=properties.getProperty("url"); username=properties.getProperty("username"); password=properties.getProperty("password"); } public static Connection getConnection(){ Connection connection=null; try { Class.forName(driver); connection= Drive
java BaseDao基本代码
最新推荐文章于 2024-07-30 20:50:32 发布