Magentix2
2.1.1
|
Public Member Functions | |
Connection | connect () |
Protected Member Functions | |
void | finalize () |
This class is responsible for connection and database queries.
Definition at line 14 of file DataBaseAccess.java.
Connection es.upv.dsic.gti_ia.organization.DataBaseAccess.connect | ( | ) |
This method sets the connection with the THOMAS database
Definition at line 23 of file DataBaseAccess.java.
{ try { Configuration c = Configuration.getConfiguration(); //Register a MySQL driver. String driverName = c.getjenadbDriver(); // MySQL MM JDBC // driver Class.forName(driverName).newInstance(); String serverName = c.getdatabaseServer(); String mydatabase = c.getdatabaseName(); String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a String username = c.getdatabaseUser(); String password = c.getdatabasePassword(); connection = DriverManager.getConnection(url, username, password); connection.setAutoCommit(false); connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); return connection; } catch (Exception e) { e.printStackTrace(); return null; } }
void es.upv.dsic.gti_ia.organization.DataBaseAccess.finalize | ( | ) | [protected] |
Definition at line 54 of file DataBaseAccess.java.
{ try { if (connection != null || !connection.isClosed()) connection.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }