Back to project page 29onlinemultiplayer.
The source code is released under:
MIT License
If you think the Android project 29onlinemultiplayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; //w w w.j a va 2s.c o m /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Shaheed */ public class DatabaseHandler { private final String DATABASE_URL = "jdbc:mysql://localhost/base29"; private final String DATABASE_USER = "root"; private final String DATABASE_PASSWORD = ""; private Connection conn = null; public Connection makeConnection(){ try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex); } try{ conn = DriverManager.getConnection(DATABASE_URL,DATABASE_USER,DATABASE_PASSWORD); }catch(SQLException ex){ ex.printStackTrace(); } return conn; } public void closeAllConnections(Connection connection,Statement stmt){ if(stmt != null){ try { stmt.close(); } catch (SQLException ex) { Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex); } } if(connection != null){ try { connection.close(); } catch (SQLException ex) { Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex); } } } public void closeAllConnections(Connection connection){ if(connection != null){ try { connection.close(); } catch (SQLException ex) { Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex); } } } }