public class SQLUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DB_DB2 |
static int |
DB_MSSQL |
static int |
DB_MYSQL |
static int |
DB_NONE |
static int |
DB_ORACLE |
static int |
DB_POSTGRES |
static int |
DB_SYBASE |
static int |
DB_TERADATA |
protected static int |
MAXLENGTH |
static int |
SQL_BLOB |
static int |
SQL_BYTE |
static int |
SQL_BYTES |
static int |
SQL_CLOB |
static int |
SQL_DATE |
static int |
SQL_DOUBLE |
static int |
SQL_FLOAT |
static int |
SQL_INT |
static int |
SQL_LONG |
static int |
SQL_NULL |
static int |
SQL_STRING |
static int |
SQL_TIME |
static int |
SQL_TIMESTAMP |
Constructor and Description |
---|
SQLUtils() |
Modifier and Type | Method and Description |
---|---|
protected static int |
copyBytes(java.io.InputStream in,
java.io.OutputStream out,
int maxBytes,
byte[] buffer)
It copies bytes from the InputStream and writes them into the
OutputStream.
|
protected static int |
copyChars(java.io.Reader in,
java.io.Writer out,
int maxBytes,
char[] buffer)
It copies chars from the Reader and writes them into the Writer.
|
static int |
fromBLOB(java.sql.Blob b,
java.io.OutputStream out)
It reads bytes from a JDBC BLOB and writes them into the OutputStream.
|
static int |
fromBLOB(java.sql.Blob b,
java.lang.StringBuffer strBuf)
It reads bytes from the BLOB and writes them into the StringBuffer.
|
static int |
fromCLOB(java.sql.Clob c,
java.lang.StringBuffer strBuf)
It reads chars from the CLOB and writes them into the StringBuffer.
|
static int |
fromCLOB(java.sql.Clob c,
java.io.Writer out)
It reads chars from the CLOB and writes them into the output writer.
|
static java.lang.String |
getParamInfo(java.lang.String sqlText,
java.util.Map map)
It parses the SQL text to look for any named parameters.
|
static java.lang.StringBuffer |
getResult(int type,
java.sql.ResultSet rset,
int[] rc)
It gets all the records from the ReseulSet and packs them into a
StringBuffer according to the ResultType.
|
static int |
getResult(int type,
java.sql.ResultSet rset,
java.util.List<java.lang.Object> list)
It gets all the records from the ReseulSet and packs them into an
List according to the ResultType.
|
static java.lang.StringBuffer |
getResult(int type,
java.lang.String[] keys,
java.util.List list)
It gets all the records from the list and packs them into a
StringBuffer according to the ResultType.
|
static java.lang.String[] |
getTables(java.lang.String query)
It parses the SQL query and returns a list of the table names
in upper case on which the query is against.
|
static void |
setParameter(int id,
int type,
java.sql.PreparedStatement stmt,
java.lang.String data)
It is not MT-safe due to sharing the default dateFormat
|
static void |
setParameter(int id,
int type,
java.sql.PreparedStatement stmt,
java.lang.String data,
java.text.SimpleDateFormat df)
It translates the data in String into the right data type and set
the value according to its index on the PreparedStatement.
|
public static final int SQL_NULL
public static final int SQL_BYTE
public static final int SQL_BYTES
public static final int SQL_STRING
public static final int SQL_INT
public static final int SQL_LONG
public static final int SQL_FLOAT
public static final int SQL_DOUBLE
public static final int SQL_DATE
public static final int SQL_CLOB
public static final int SQL_BLOB
public static final int SQL_TIME
public static final int SQL_TIMESTAMP
public static final int DB_NONE
public static final int DB_ORACLE
public static final int DB_DB2
public static final int DB_SYBASE
public static final int DB_MSSQL
public static final int DB_TERADATA
public static final int DB_POSTGRES
public static final int DB_MYSQL
protected static final int MAXLENGTH
public static java.lang.String getParamInfo(java.lang.String sqlText, java.util.Map map)
public static void setParameter(int id, int type, java.sql.PreparedStatement stmt, java.lang.String data, java.text.SimpleDateFormat df) throws java.sql.SQLException
java.sql.SQLException
public static void setParameter(int id, int type, java.sql.PreparedStatement stmt, java.lang.String data) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.StringBuffer getResult(int type, java.sql.ResultSet rset, int[] rc) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public static int getResult(int type, java.sql.ResultSet rset, java.util.List<java.lang.Object> list) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public static java.lang.StringBuffer getResult(int type, java.lang.String[] keys, java.util.List list)
public static int fromBLOB(java.sql.Blob b, java.io.OutputStream out) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public static int fromBLOB(java.sql.Blob b, java.lang.StringBuffer strBuf) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public static int fromCLOB(java.sql.Clob c, java.io.Writer out) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public static int fromCLOB(java.sql.Clob c, java.lang.StringBuffer strBuf) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
protected static int copyBytes(java.io.InputStream in, java.io.OutputStream out, int maxBytes, byte[] buffer) throws java.io.IOException
java.io.IOException
protected static int copyChars(java.io.Reader in, java.io.Writer out, int maxBytes, char[] buffer) throws java.io.IOException
java.io.IOException
public static java.lang.String[] getTables(java.lang.String query)