Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DBConn {
- Statement stmt = null;
- ResultSet rs = null;
- Connection con = null;
- static{
- try {
- // TREIBER LADEN
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static Connection openConnection(){
- // WOHIN WIR WOLLEN
- String connectionUrl = "jdbc:mysql://URL/;databaseName=NDDMA;";
- String url ="jdbc:mysql://URL:PORT";
- Connection con = null;
- try {
- con = DriverManager.getConnection(url,"USER", "PW");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return con;
- }
- public void closeConnection(Connection con,Statement stmt,ResultSet rs){
- try {
- rs.close();
- stmt.close();
- con.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement