Magentix2  2.1.1
es.upv.dsic.gti_ia.organization.DataBaseAccess Class Reference

List of all members.

Public Member Functions

Connection connect ()

Protected Member Functions

void finalize ()

Detailed Description

This class is responsible for connection and database queries.

Definition at line 14 of file DataBaseAccess.java.


Member Function Documentation

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;
                }
        }

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();
                }
        }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables