public class Types extends java.lang.Object
Constructor and Description |
---|
Types(SystemLog log,
PropertyMgr props)
Constructs a new object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getJavaTypeFromSQLType(int java_sql_type,
fc.jdbc.dbo.ColumnData cd)
Converts a value corresponding to
java.sql.Type to the Java
type used to represent that type. |
java.lang.String |
getPreparedStmtSetMethod(int java_sql_type,
java.lang.String psvar,
java.lang.String pos,
java.lang.String varname,
fc.jdbc.dbo.ColumnData cd)
Returns a suitable setXXX method name to set the prepared statement
placeholder data for some column.
|
java.lang.String |
getPreparedStmtSetNullMethod(int java_sql_type,
java.lang.String pos,
java.lang.String varname,
fc.jdbc.dbo.ColumnData cd) |
java.lang.String |
getResultSetMethod(int java_sql_type,
java.lang.String pos,
fc.jdbc.dbo.ColumnData cd)
Returns a suitable getResultXXX method name to retrieve
the data for some column.
|
java.lang.String |
getRuntimeResultSetMethod(int java_sql_type,
java.lang.String name,
fc.jdbc.dbo.ColumnData cd)
Returns a suitable getResultXXX method name to retrieve
the data for some column (which will use a runtime prefix argument
prepended to the column name).
|
java.lang.String |
getSQLTypeName(int java_sql_type)
Converts the
java.sql.Type for some column (returned by the
driver) to a readable value. |
boolean |
usesPrimitiveJavaType(int java_sql_type,
fc.jdbc.dbo.ColumnData cd)
Uses the same conversion criteria as the
getJavaTypeFromSQLType()
and then returns true if the Java type used to represent the
specified java.sql.Type is primitive (int, boolean etc) as opposed
to an Object type. |
boolean |
usesSimpleIntegralJavaType(int java_sql_type)
Uses the same conversion criteria as the
getJavaTypeFromSQLType()
and then returns true if the Java type used to represent the
specified java.sql.Type is integral. |
public Types(SystemLog log, PropertyMgr props)
log
- logging destinationprops
- PropertyManager that may contain:
If the above key values are missing, then the defaults are used (see usage info for
- dbspecific.mysql.boolean_hack
- generate.preparedstatement.setxxx.length_param
Generate
)
public java.lang.String getResultSetMethod(int java_sql_type, java.lang.String pos, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
java_sql_type
- the java.sql.Type
corresponding
to the column for which the method will
be generatedpos
- A string containing the column index
number (starts from 1)java.sql.SQLException
public java.lang.String getRuntimeResultSetMethod(int java_sql_type, java.lang.String name, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
java_sql_type
- the java.sql.Type
corresponding
to the column for which the method will
be generatedname
- column namejava.sql.SQLException
public java.lang.String getPreparedStmtSetMethod(int java_sql_type, java.lang.String psvar, java.lang.String pos, java.lang.String varname, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
java_sql_type
- the java.sql.Type
corresponding
to the column for which the method will
be generatedpos
- a String containing the column index number
(starts from 1) or a runtime value
to insert in generate code like "pos++"varname
- the name of the variable containing the
value to be set at runtime.java.sql.SQLException
public java.lang.String getPreparedStmtSetNullMethod(int java_sql_type, java.lang.String pos, java.lang.String varname, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getJavaTypeFromSQLType(int java_sql_type, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
java.sql.Type
to the Java
type used to represent that type. The Sql-Type
is
returned by the jdbc driver for some column in a table and we map it to a
corresponding java type that will be used to represent/work with that sql
type in our java programs. This mapping follows the JDBC guidelines.
Similar JDBC API method like ResultSetMetaData#getColumnTypeName(column)
and DatabaseMetaData#getColumns()
return tpye names that can be driver/db
specific (and don't have to correspond to Java types anyway).java_sql_type
- the java.sql.Type
to convert to a
java language typecd
- used to find out if the column is nullable
(this can have the effect of using primitive or
object types, in some cases, for example, Boolean
vs boolean)java.sql.SQLException
public boolean usesPrimitiveJavaType(int java_sql_type, fc.jdbc.dbo.ColumnData cd) throws java.sql.SQLException
getJavaTypeFromSQLType()
and then returns true if the Java type used to represent the
specified java.sql.Type
is primitive (int, boolean etc) as opposed
to an Object type.java_sql_type
- the java.sql.Type
for the corresponding
java type.cd
- used to find out if the column is nullable
(this can have the effect of using primitive or
object types, in some cases, for example, Boolean
vs boolean)java.sql.SQLException
public boolean usesSimpleIntegralJavaType(int java_sql_type) throws java.sql.SQLException
getJavaTypeFromSQLType()
and then returns true if the Java type used to represent the
specified java.sql.Type
is integral. This is used for creating
the inc/dec methods (only for short, int and long)java_sql_type
- the java.sql.Type
for the corresponding
java typejava.sql.SQLException
public java.lang.String getSQLTypeName(int java_sql_type)
java.sql.Type
for some column (returned by the
driver) to a readable value. More convenient than using the "constant
field values" section of the not neatly arranged javadocs for java.sql.Type
.
Note, this method is different from because unlike , this simply returns the variable name corresponding to the parameter value (for example, java.sql.Type.INTEGER == 4 and passing 4 to this method will return "INTEGER").
java_sql_type
- a type from java.sql.Type