|
||||||||||
| 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
ch.sahits.codegen.java.input.db.MySQLConnection
public class MySQLConnection
This class handles the connection to a MySQL DB. It queries the DB for the structure of a table.
| Field Summary |
|---|
| Fields inherited from class ch.sahits.codegen.java.input.db.DBConnection |
|---|
conn, db, host, password, port, product, schema, table, user |
| Constructor Summary | |
|---|---|
MySQLConnection()
Default constructor |
|
MySQLConnection(java.lang.String _product,
java.lang.String hostname,
java.lang.String uname,
java.lang.String pwd,
java.lang.String database,
java.lang.String tablename,
java.lang.String _packageName,
java.lang.String _className,
int _port,
java.lang.String _schema)
Constructor initializes the connection data This constructor is only used for tests |
|
| Method Summary | |
|---|---|
protected java.lang.Class |
convert2Java(java.lang.String type)
Convert a database datatype into a Java type |
static java.lang.Class |
convert2JavaType(java.lang.String type)
Convert the corresponding Java type for a database type |
protected DataBaseTable |
createDataBaseTable()
Create the DataBaseTable with product specific data |
java.lang.String |
getConnectionDriverClass()
Retrieve the driver class name for the JDBC connection |
java.lang.String |
getConnectionString()
Retrieve the connection String for the specific database |
protected java.lang.String |
getConstraintFieldSQL(java.lang.String constraintName)
Retrieve the SQL that gets you all fields of a constraint |
protected java.lang.String |
getIndexConstraintSQL()
Retrieve the SQL that gets you the Index constraints |
protected java.lang.String |
getTableSQL()
Retrieve the SQL that gets you the table definition |
protected void |
loadDriver()
check if the driver is available |
| Methods inherited from class ch.sahits.codegen.java.input.db.DBConnection |
|---|
addFields2Index, getConstraintsFields, getPort, getSchema, getStructure, init, isAutGenKey, setHost, setPassword, setPort, setProduct, setSchema, setTableName, setUserName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MySQLConnection(java.lang.String _product,
java.lang.String hostname,
java.lang.String uname,
java.lang.String pwd,
java.lang.String database,
java.lang.String tablename,
java.lang.String _packageName,
java.lang.String _className,
int _port,
java.lang.String _schema)
throws java.sql.SQLException
_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_packageName - name of the package_className - name of the class_port - number_schema - name
java.sql.SQLException - Connecting failed probably due to incorrect inputpublic MySQLConnection()
| Method Detail |
|---|
public final java.lang.String getConnectionString()
getConnectionString in class DBConnectionprotected final java.lang.String getConstraintFieldSQL(java.lang.String constraintName)
getConstraintFieldSQL in class DBConnectionconstraintName - name of the constraint
protected final void loadDriver()
throws java.lang.ClassNotFoundException
loadDriver in class DBConnectionjava.lang.ClassNotFoundException - JDBC driver not on classpathpublic final java.lang.String getConnectionDriverClass()
public static java.lang.Class convert2JavaType(java.lang.String type)
type - database type
protected final DataBaseTable createDataBaseTable()
DataBaseTable with product specific data
createDataBaseTable in class DBConnectionDataBaseTableprotected final java.lang.String getIndexConstraintSQL()
getIndexConstraintSQL in class DBConnectionprotected final java.lang.String getTableSQL()
getTableSQL in class DBConnectionprotected final java.lang.Class convert2Java(java.lang.String type)
convert2Java in class DBConnectiontype - datatype
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||