class="java" name="code">package export.util; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; public class DBUtil { private static String url; private static String driver; private static String user; private static String password; /** * driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/mydb username=root password=root */ static{ InputStream inputStream = DBUtil.class.getClassLoader().getResourceAsStream("export/util/db.properties"); Properties proper = new Properties(); try { proper.load(inputStream); driver = proper.getProperty("driver"); url = proper.getProperty("url"); user = proper.getProperty("username"); password = proper.getProperty("password"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static Connection getConn(){ Connection conn = null; try { Class.forName(driver); conn = DriverManager.getConnection(url, user, password); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return conn; } }