com.partnersoft.sql
Class SqlLib

java.lang.Object
  extended by com.partnersoft.sql.SqlLib
All Implemented Interfaces:
Lib

public class SqlLib
extends java.lang.Object
implements Lib

SQL convenience methods.

Copyright 2000-2007 Partner Software, Inc.

Version:
$Id: SqlLib.java 2328 2010-01-06 15:38:22Z paul $
Author:
Brad Gray, Paul Reavis

Method Summary
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.Object convertToJavaObject(java.lang.Object sqlObject)
          Attempts to convert the given JDBC-type object to non-JDBC object.
static java.lang.Object convertToSqlObject(java.lang.Object javaObject)
          Attempts to convert the given object to one that will be understood by JDBC SQL (e.g.
static java.lang.String convertToString(java.lang.Object victim)
          Does smart conversion on objects to turn them into SQL-compatible strings.
static java.lang.String convertToStringAndQuote(java.lang.Object victim)
          Does smart conversion on objects to turn them into SQL-compatible values.
static java.lang.String makeUrl(SqlDatabase config)
           
static java.lang.String makeUrl(SqlType type, java.lang.String server, java.lang.String database, java.lang.String databasePath, java.lang.String properties)
           
static void setParameters(java.sql.PreparedStatement statement, java.util.List<java.lang.Object> parameters)
          Sets the parameters in a PreparedStatement from the given List.
static void setParameters(java.sql.PreparedStatement statement, java.lang.Object... parameters)
          Sets the parameters in a PreparedStatement from the given array.
static boolean sqlTypeRequiresLength(int sqlType)
          Returns true if the type requires a length specification.
static java.lang.Class sqlTypeToJavaType(int sqlType)
          Returns the Java class corresponding to the given SQL type.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeUrl

public static java.lang.String makeUrl(SqlDatabase config)

makeUrl

public static java.lang.String makeUrl(SqlType type,
                                       java.lang.String server,
                                       java.lang.String database,
                                       java.lang.String databasePath,
                                       java.lang.String properties)

setParameters

public static void setParameters(java.sql.PreparedStatement statement,
                                 java.lang.Object... parameters)
                          throws java.sql.SQLException
Sets the parameters in a PreparedStatement from the given array.

Throws:
java.sql.SQLException

setParameters

public static void setParameters(java.sql.PreparedStatement statement,
                                 java.util.List<java.lang.Object> parameters)
                          throws java.sql.SQLException
Sets the parameters in a PreparedStatement from the given List.

Throws:
java.sql.SQLException

sqlTypeToString

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


sqlTypeToJavaType

public static java.lang.Class sqlTypeToJavaType(int sqlType)
Returns the Java class corresponding to the given SQL type.


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.


convertToSqlObject

public static java.lang.Object convertToSqlObject(java.lang.Object javaObject)
Attempts to convert the given object to one that will be understood by JDBC SQL (e.g. in a parameterized, prepared statement).


convertToJavaObject

public static java.lang.Object convertToJavaObject(java.lang.Object sqlObject)
Attempts to convert the given JDBC-type object to non-JDBC object.


convertToString

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


convertToStringAndQuote

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


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