com.partnersoft.v3x.io.sql
Class SQLLib

java.lang.Object
  extended by com.partnersoft.v3x.io.sql.SQLLib

public class SQLLib
extends java.lang.Object

Convenience methods for formating sql statements assumes that the Map is in the format ("table attribute", "bean graph map to value") example : fieldA , info.fieldA


Constructor Summary
SQLLib()
           
 
Method Summary
static java.lang.String buildCreateStatementFor(java.sql.Connection connexion, java.lang.String tableName)
          Returns a String containing a create table statement for the given table on the given connection.
static java.lang.String buildCreateStatementFor(java.sql.ResultSet results, java.lang.String tableName)
          Returns a String containing a create table statement for the given table on the given connection.
static java.lang.String convert(java.lang.Object victim)
          Does smart conversion on objects to turn them into SQL-compatible strings.
static java.lang.String convertAndQuote(java.lang.Object victim)
          Does smart conversion on objects to turn them into SQL-compatible values.
static java.lang.String createStatement(java.lang.String tableName, java.util.Map properties)
          returns a SQL create table statement.
static java.lang.String createStatement(java.lang.String tableName, java.util.Map properties, java.util.ArrayList prepend)
          this is a little kludgey but it allows for forced prepending of data that perhaps isn't included in the object being processed...
static java.lang.String insertStatement(java.lang.String tableName, java.lang.Object o, java.util.Map properties)
          returns a SQL insert into table statement
static java.lang.String insertStatement(java.lang.String tableName, java.lang.Object o, java.util.Map properties, java.util.ArrayList prepend)
          this is a little kludgey but it allows for forced prepending of data that perhaps isn't included in the object being processed...
static java.util.ArrayList listCatalogs(java.sql.Connection connexion)
          Lists catalog names in a database.
static java.util.ArrayList listColumns(java.sql.Connection connexion, java.lang.String tableName)
          Lists columns names in a database table.
static java.util.ArrayList listSchemas(java.sql.Connection connexion)
          Lists schema names in a database.
static java.util.Map listTableOwners(java.sql.Connection connexion)
          Lists tables and their owners in a database.
static java.util.ArrayList listTables(java.sql.Connection connexion)
          Lists table names in a database.
static java.lang.String oneFieldQuery(java.sql.Connection connexion, java.lang.String query)
           
static java.util.Map resultSetToMap(java.sql.ResultSet results)
           
static boolean sqlTypeRequiresLength(int sqlType)
          Returns true if the type requires a length specification.
static java.lang.String sqlTypeToMySQLString(int sqlType)
          Returns a string representation of the MySQL equivalent of an SQL column type ID code.
static java.lang.String sqlTypeToMySQLString(int sqlType, int size)
          Returns a string representation of the MySQL equivalent of an SQL column type ID code.
static java.lang.String sqlTypeToString(int sqlType)
          Returns a string representation of an SQL column type ID code.
static java.util.Set tablesInQuery(java.lang.String query)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLLib

public SQLLib()
Method Detail

resultSetToMap

public static java.util.Map resultSetToMap(java.sql.ResultSet results)
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

createStatement

public static java.lang.String createStatement(java.lang.String tableName,
                                               java.util.Map properties)
returns a SQL create table statement.


insertStatement

public static java.lang.String insertStatement(java.lang.String tableName,
                                               java.lang.Object o,
                                               java.util.Map properties)
returns a SQL insert into table statement


insertStatement

public static java.lang.String insertStatement(java.lang.String tableName,
                                               java.lang.Object o,
                                               java.util.Map properties,
                                               java.util.ArrayList prepend)
this is a little kludgey but it allows for forced prepending of data that perhaps isn't included in the object being processed...


createStatement

public static java.lang.String createStatement(java.lang.String tableName,
                                               java.util.Map properties,
                                               java.util.ArrayList prepend)
this is a little kludgey but it allows for forced prepending of data that perhaps isn't included in the object being processed...


convert

public static java.lang.String convert(java.lang.Object victim)
Does smart conversion on objects to turn them into SQL-compatible strings.


convertAndQuote

public static java.lang.String convertAndQuote(java.lang.Object victim)
Does smart conversion on objects to turn them into SQL-compatible values. Adds quotes if appropriate.


listTables

public static java.util.ArrayList listTables(java.sql.Connection connexion)
                                      throws java.sql.SQLException
Lists table names in a database.

Throws:
java.sql.SQLException

listTableOwners

public static java.util.Map listTableOwners(java.sql.Connection connexion)
                                     throws java.sql.SQLException
Lists tables and their owners in a database.

Throws:
java.sql.SQLException

tablesInQuery

public static java.util.Set tablesInQuery(java.lang.String query)

listCatalogs

public static java.util.ArrayList listCatalogs(java.sql.Connection connexion)
                                        throws java.sql.SQLException
Lists catalog names in a database.

Throws:
java.sql.SQLException

listSchemas

public static java.util.ArrayList listSchemas(java.sql.Connection connexion)
                                       throws java.sql.SQLException
Lists schema names in a database.

Throws:
java.sql.SQLException

oneFieldQuery

public static java.lang.String oneFieldQuery(java.sql.Connection connexion,
                                             java.lang.String query)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

listColumns

public static java.util.ArrayList listColumns(java.sql.Connection connexion,
                                              java.lang.String tableName)
                                       throws java.sql.SQLException
Lists columns names in a database table.

Throws:
java.sql.SQLException

buildCreateStatementFor

public static java.lang.String buildCreateStatementFor(java.sql.Connection connexion,
                                                       java.lang.String tableName)
                                                throws java.sql.SQLException
Returns a String containing a create table statement for the given table on the given connection.

Throws:
java.sql.SQLException

buildCreateStatementFor

public static java.lang.String buildCreateStatementFor(java.sql.ResultSet results,
                                                       java.lang.String tableName)
                                                throws java.sql.SQLException
Returns a String containing a create table statement for the given table on the given connection.

Throws:
java.sql.SQLException

sqlTypeToString

public static java.lang.String sqlTypeToString(int sqlType)
Returns a string representation of an SQL column type ID code.


sqlTypeToMySQLString

public static java.lang.String sqlTypeToMySQLString(int sqlType)
Returns a string representation of the MySQL equivalent of an SQL column type ID code.


sqlTypeToMySQLString

public static java.lang.String sqlTypeToMySQLString(int sqlType,
                                                    int size)
Returns a string representation of the MySQL equivalent of an SQL column type ID code.


sqlTypeRequiresLength

public static boolean sqlTypeRequiresLength(int sqlType)
Returns true if the type requires a length specification.