Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ro.scoalainformala.jdbc.helper;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.Properties;
- public class DBHelper {
- public static Connection openConnection() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- }
- Properties connectionProps = new Properties();
- connectionProps.put("user", "root");
- connectionProps.put("password", "1qa2ws3ed");
- try {
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bank_curs", connectionProps);
- return conn;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static void closeConnection(Connection conn) {
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement