Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package LaLiga;
- import com.mysql.jdbc.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- /**
- *
- * @author Lucaso1989
- */
- public class DataBaseConnection {
- private Connection DataBaseConnection;
- public DataBaseConnection() {
- }
- public void init() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- DataBaseConnection = (Connection) DriverManager.getConnection(
- "jdbc:mysql://db4free.net/laliga","lukkas", "b1a8r9c9a"
- );
- }
- catch(Exception e){
- System.out.println("Failed to get connection");
- e.printStackTrace();
- }
- }
- public Connection getConnection(){
- return DataBaseConnection;
- }
- public void close(ResultSet rs){
- if(rs !=null){
- try{
- rs.close();
- }
- catch(Exception e){}
- }
- }
- public void close(java.sql.Statement stmt){
- if(stmt !=null){
- try{
- stmt.close();
- }
- catch(Exception e){}
- }
- }
- public void destroy(){
- if(DataBaseConnection !=null){
- try{
- DataBaseConnection.close();
- }
- catch(Exception e){}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement