ch.sahits.phpclassgenerator
Class DBConnection

java.lang.Object
  extended by ch.sahits.phpclassgenerator.DBConnection
Direct Known Subclasses:
MySQLConnection

public abstract class DBConnection
extends java.lang.Object

This abstract class handles the connection to the DB. It queries the DB for the structure of a table. Supported DBs are

Version:
1.0 $Revision: 1.3 $ changed by $Author: hotzst $ at $Date: 2007/08/18 16:39:05 $
Author:
Andi Hotz, (c) 2007

Field Summary
protected  java.sql.Connection conn
          Connection to the DB
protected  java.lang.String db
          DB on the server
protected  java.lang.String host
          Host name of the server where the DB is hosted
protected  java.lang.String password
          Password for the User
protected  java.lang.String product
          What DB are we talking about MySQL, Oracle, MSSQL, PostgSQL, ...
protected  java.lang.String table
          Table to query
protected  java.lang.String user
          User to query the DB
 
Constructor Summary
protected DBConnection(java.lang.String product, java.lang.String hostname, java.lang.String uname, java.lang.String pwd, java.lang.String database, java.lang.String tablename)
          Constructor initializes the connection data
 
Method Summary
protected abstract  DBStructure getStructure()
          Generates a DBStructure Object for the table.
protected abstract  void loadDriver()
          check if the driver is available
 void setHost(java.lang.String host)
           
 void setPassword(java.lang.String password)
           
 void setProduct(java.lang.String product)
           
 void setTable(java.lang.String table)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected java.sql.Connection conn
Connection to the DB


host

protected java.lang.String host
Host name of the server where the DB is hosted


product

protected java.lang.String product
What DB are we talking about MySQL, Oracle, MSSQL, PostgSQL, ...


user

protected java.lang.String user
User to query the DB


password

protected java.lang.String password
Password for the User


table

protected java.lang.String table
Table to query


db

protected java.lang.String db
DB on the server

Constructor Detail

DBConnection

protected DBConnection(java.lang.String product,
                       java.lang.String hostname,
                       java.lang.String uname,
                       java.lang.String pwd,
                       java.lang.String database,
                       java.lang.String tablename)
                throws java.sql.SQLException
Constructor initializes the connection data

Parameters:
product - what kind of DB (MySQL, PostgeSQL, Oracle, Derby, MS SQL Server, ...)
hostname - of the db eg. localhost
uname - user name to connect to the DB
pwd - password of the user
database - or schema of the table
tablename - table name
Throws:
java.sql.SQLException - Connecting failed probably due to incorrect input
Method Detail

loadDriver

protected abstract void loadDriver()
check if the driver is available


setHost

public void setHost(java.lang.String host)
Parameters:
host - the host to set
See Also:
host

setProduct

public void setProduct(java.lang.String product)
Parameters:
product - the product to set
See Also:
product

setUser

public void setUser(java.lang.String user)
Parameters:
user - the user to set
See Also:
user

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - the password to set
See Also:
password

setTable

public void setTable(java.lang.String table)
Parameters:
table - the table to set
See Also:
table

getStructure

protected abstract DBStructure getStructure()
                                     throws java.sql.SQLException
Generates a DBStructure Object for the table.

Returns:
DBStructure
Throws:
java.sql.SQLException