Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ro.scoalainformala.bankjdbc.helper;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.Properties;
- public class DBHelper {
- public static Connection getConnection() {
- Properties connectionProperties = new Properties();
- connectionProperties.put("user", "root");
- connectionProperties.put("password", "mircea");
- String connString = "jdbc:mysql://localhost:3306/bank_curs";
- try {
- Connection con = DriverManager.getConnection(connString, connectionProperties);
- System.out.println("Conexiunea la baza de date a fost deschisa");
- return con;
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
- public static void closeConnection(Connection con) {
- try {
- con.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement