ch.sahits.codegen.java.input.db
Class SQLServerConnection

java.lang.Object
  extended by ch.sahits.codegen.java.input.db.DBConnection
      extended by ch.sahits.codegen.java.input.db.SQLServerConnection
Direct Known Subclasses:
SQLServerConnectionModelGenerator

public class SQLServerConnection
extends DBConnection

This class handles the connection to a SQL Server DB. It queries the DB for the structure of a table.

Since:
0.9.5
Author:
Andi Hotz, (c) 2008

Field Summary
 
Fields inherited from class ch.sahits.codegen.java.input.db.DBConnection
conn, db, host, password, port, product, schema, table, user
 
Constructor Summary
SQLServerConnection()
          Default constructor
SQLServerConnection(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
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

SQLServerConnection

public SQLServerConnection(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
Constructor initializes the connection data This constructor is only used for tests

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
_packageName - name of the package
_className - name of the class
_port - number
_schema - name
Throws:
java.sql.SQLException - Connecting failed probably due to incorrect input

SQLServerConnection

public SQLServerConnection()
Default constructor

Method Detail

getConnectionString

public final java.lang.String getConnectionString()
Retrieve the connection String for the specific database

Specified by:
getConnectionString in class DBConnection
Returns:
connection string
Since:
0.9.45

loadDriver

protected final void loadDriver()
                         throws java.lang.ClassNotFoundException
check if the driver is available

Specified by:
loadDriver in class DBConnection
Throws:
java.lang.ClassNotFoundException - JDBC driver not on classpath

getConnectionDriverClass

public final java.lang.String getConnectionDriverClass()
Retrieve the driver class name for the JDBC connection

Returns:
fully qualified driver class name
Since:
1.2.0

getConstraintFieldSQL

protected final java.lang.String getConstraintFieldSQL(java.lang.String constraintName)
Retrieve the SQL that gets you all fields of a constraint

Specified by:
getConstraintFieldSQL in class DBConnection
Parameters:
constraintName - name of the constraint
Returns:
SQL

convert2Java

protected final java.lang.Class convert2Java(java.lang.String type)
Convert a database datatype into a Java type

Specified by:
convert2Java in class DBConnection
Parameters:
type - datatype
Returns:
Java type
Since:
0.9.5

createDataBaseTable

protected final DataBaseTable createDataBaseTable()
Create the DataBaseTable with product specific data

Specified by:
createDataBaseTable in class DBConnection
Returns:
new DataBaseTable
Since:
0.9.5

getIndexConstraintSQL

protected final java.lang.String getIndexConstraintSQL()
Retrieve the SQL that gets you the Index constraints

Specified by:
getIndexConstraintSQL in class DBConnection
Returns:
SQL
Since:
0.9.5

getTableSQL

protected final java.lang.String getTableSQL()
Retrieve the SQL that gets you the table definition

Specified by:
getTableSQL in class DBConnection
Returns:
SQL
Since:
0.9.5