Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.infosoftglobal.fusioncharts
Class DBConnection

    java.lang.Object
      com.infosoftglobal.fusioncharts.DBConnection

    public class DBConnection

extends java.lang.Object

Contains methods to get a connection to the database.
The database used here is MySQL
This class contains code to connect to the database
The DSN looked up for connection is "jdbc/FactoryDB". Please configure the same DSN in your server.
Only one instance of this class should ideally be used throughout your application.
For demo purpose, we have kept the default constructor available to all classes.
Ideally you would override the default constructor and write a getInstance method which will
return a single DBConnection instance always,thus making it a singleton class.

Author:
  InfoSoft Global (P) Ltd.

Constructor Summary
`DBConnection()`

Method Summary
`java.sql.Connection` | `getConnection()` Returns a connection to a database as configured earlier. This method can be used by all the jsps to get a connection. The jsps do not have to worry about which db to connect to etc. This has been configured in this class by the InitServlet.
`private java.sql.Connection` | `getConnectionByDSN(java.lang.String dataSourceName)` Opens the connection to the MySQL Database Using the DataSource Name specified in the config file of the server in which it is deployed. In real world applications,some sort of connection pooling mechanism would be used for getting the connection and proper care would be taken to close it when the work is done.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DBConnection

    public DBConnection()

Method Detail

### getConnection

    public java.sql.Connection getConnection()

  Returns a connection to a database as configured earlier.
  This method can be used by all the jsps to get a connection.
  The jsps do not have to worry about which db to connect to etc.
  This has been configured in this class by the InitServlet.

  Returns:
    Connection - a connection to the specific database based on the configuration

### getConnectionByDSN

    private java.sql.Connection getConnectionByDSN(java.lang.String dataSourceName)

  Opens the connection to the MySQL Database
  Using the DataSource Name specified in the config file of the server in which it is deployed.
  In real world applications,some sort of connection pooling mechanism
  would be used for getting the connection and proper care would be taken to
  close it when the work is done.

  Returns:
    Connection a connection to the MySQL database

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD