|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.sahits.codegen.java.input.db.DBConnection
public abstract class DBConnection
This abstract class handles the connection to the DB. It queries the DB for the structure of a table. Supported DBs are
| 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 int |
port
Port number |
protected java.lang.String |
product
What DB are we talking about MySQL, Oracle, MSSQL, PostgSQL, ... |
protected java.lang.String |
schema
Schema name. |
protected java.lang.String |
table
Table to query |
protected java.lang.String |
user
User to query the DB |
| Constructor Summary | |
|---|---|
DBConnection()
|
|
| Method Summary | |
|---|---|
protected void |
addFields2Index(DataBaseTable struct,
DataBaseTableIndex index,
java.lang.String consteintName)
Add fields to the index model |
protected abstract java.lang.Class |
convert2Java(java.lang.String type)
Convert a database datatype into a Java type |
protected abstract DataBaseTable |
createDataBaseTable()
Create the DataBaseTable with product specific data |
protected abstract java.lang.String |
getConnectionString()
Retrieve the connection String for the specific database |
protected abstract java.lang.String |
getConstraintFieldSQL(java.lang.String constraintName)
Retrieve the SQL that gets you all fields of a constraint |
protected java.util.List<java.lang.String> |
getConstraintsFields(java.lang.String constraintName)
Retrieve a list of all of all fields of a constraint |
protected abstract java.lang.String |
getIndexConstraintSQL()
Retrieve the SQL that gets you the Index constraints |
int |
getPort()
|
java.lang.String |
getSchema()
|
protected DataBaseTable |
getStructure()
Generates a DBStructure Object for the table. |
protected abstract java.lang.String |
getTableSQL()
Retrieve the SQL that gets you the table definition |
protected void |
init(java.lang.String _product,
java.lang.String hostname,
java.lang.String uname,
java.lang.String pwd,
java.lang.String database,
java.lang.String tablename,
int _port,
java.lang.String _schema)
Initializes the connection data |
protected boolean |
isAutGenKey(java.lang.String fieldName)
Check if the field is an auto generated key field |
protected abstract void |
loadDriver()
check if the driver is availabel |
void |
setHost(java.lang.String _host)
|
void |
setPassword(java.lang.String _password)
|
void |
setPort(int _port)
|
void |
setProduct(java.lang.String _product)
|
void |
setSchema(java.lang.String _schema)
|
void |
setTableName(java.lang.String _table)
|
void |
setUserName(java.lang.String _user)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.sql.Connection conn
protected java.lang.String host
protected java.lang.String product
protected java.lang.String user
protected java.lang.String password
protected java.lang.String table
protected java.lang.String db
protected int port
protected java.lang.String schema
| Constructor Detail |
|---|
public DBConnection()
| Method Detail |
|---|
protected final void init(java.lang.String _product,
java.lang.String hostname,
java.lang.String uname,
java.lang.String pwd,
java.lang.String database,
java.lang.String tablename,
int _port,
java.lang.String _schema)
throws java.sql.SQLException,
java.lang.ClassNotFoundException
_product - what kind of DB (MySQL, PostgeSQL, Oracle, Derby, MS SQL Server, ...)hostname - of the db eg. localhostuname - user name to connect to the DBpwd - password of the userdatabase - or schema of the tabletablename - table name_port - number_schema - name
java.sql.SQLException - Connecting failed probably due to incorrect input
java.lang.ClassNotFoundException - JDBC driver not on classpathprotected abstract java.lang.String getConnectionString()
protected abstract void loadDriver()
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException - JDBC driver not on classpathpublic final void setHost(java.lang.String _host)
_host - the host to sethostpublic final void setProduct(java.lang.String _product)
_product - the product to setproductpublic final void setUserName(java.lang.String _user)
_user - the user to setuserpublic final void setPassword(java.lang.String _password)
_password - the password to setpasswordpublic final void setTableName(java.lang.String _table)
_table - the table to settable
protected DataBaseTable getStructure()
throws java.sql.SQLException
DataBaseTable
java.sql.SQLExceptionprotected abstract DataBaseTable createDataBaseTable()
DataBaseTable with product specific data
DataBaseTableprotected abstract java.lang.String getTableSQL()
protected abstract java.lang.Class convert2Java(java.lang.String type)
type - datatype
protected abstract java.lang.String getIndexConstraintSQL()
public final int getPort()
public final void setPort(int _port)
_port - the port to setpublic final java.lang.String getSchema()
public final void setSchema(java.lang.String _schema)
_schema - the schema to set
protected final void addFields2Index(DataBaseTable struct,
DataBaseTableIndex index,
java.lang.String consteintName)
throws java.sql.SQLException
struct - table modelindex - model of the indexconsteintName - name of the index
java.sql.SQLException
protected final java.util.List<java.lang.String> getConstraintsFields(java.lang.String constraintName)
throws java.sql.SQLException
constraintName - name of the constraint
java.sql.SQLException - Error while reading KEY_COLUMN_USAGEprotected abstract java.lang.String getConstraintFieldSQL(java.lang.String constraintName)
constraintName - name of the constraint
protected final boolean isAutGenKey(java.lang.String fieldName)
fieldName - name of the fiedl to be checked
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||