When you are submitting or requesting data from a database using the Database control, you may need to understand how Java data types map to SQL data types, and vice versa, in order to handle the data in your code. The table below shows the most common data type mappings, although others are possible.
In some cases, there are multiple mapping possibilities for a single type. For example, if you return data from a column of type smallint in the Pointbase sample database, you can store that data in a Java variable of type byte or type short, depending on your needs.
The type mappings shown in the tables below are the most direct mappings and are shown as examples. Please consult the documentation for your database system to determine all possible database to Java mappings in the database system you are using.
The following table lists the relationships between database types and Java types for the PointBase Version 4.4 database, which is installed with WebLogic Server. If you are using a different database, please consult the documentation for the JDBC driver of your database software.
Java Data Types | JDBC Data Types | PointBase SQL Data Types (Version 4.4) |
---|---|---|
boolean | BIT | boolean |
byte | TINYINT | smallint |
short | SMALLINT | smallint |
int | INTEGER | integer |
long | BIGINT | numberic/decimal |
double | FLOAT | real |
float | REAL | float |
double | DOUBLE | double |
java.math.BigDecimal | NUMERIC | numeric |
java.math.BigDecimal | DECIMAL | decimal |
String | CHAR | char |
String | VARCHAR | varchar |
String | LONGVARCHAR | clob |
java.sql.Date | DATE | date |
java.sql.Time | TIME | time |
java.sql.Timestamp | TIMESTAMP | timestamp |
byte[] | BINARY | blob |
byte[] | VARBINARY | blob |
byte[] | LONGVARBINARYbyte[] | blob |
java.sql.Blob | BLOB | blob |
java.sql.Clob | CLOB | clob |
For table showing the relationships between JDBC types and Microsoft SQL Server types, see Data Types in the WebLogic Server 8.1 documentation.
The following table lists the relationships between database types and Java types for the Oracle 8i database.
Java Data Types | JDBC Data Types | Oracle SQL Data Types (Version 8i) |
---|---|---|
boolean | BIT | NUMBER |
byte | TINYINT | NUMBER |
short | SMALLINT | NUMBER |
int | INTEGER | NUMBER |
long | BIGINT | NUMBER |
double | FLOAT | NUMBER |
float | REAL | NUMBER |
double | DOUBLE | NUMBER |
java.math.BigDecimal | NUMERIC | NUMBER |
java.math.BigDecimal | DECIMAL | NUMBER |
String | CHAR | CHAR |
String | VARCHAR | VARCHAR2 |
String | LONGVARCHAR | LONG |
java.sql.Date | DATE | DATE |
java.sql.Time | TIME | DATE |
java.sql.Timestamp | TIMESTAMP | DATE |
byte[] | BINARY | NUMBER |
byte[] | VARBINARY | RAW |
byte[] | LONGVARBINARY | LONGRAW |
java.sql.Blob | BLOB | BLOB |
java.sql.Clob | CLOB | CLOB |
Returning a Single Value from a Database Control Method
Returning a Single Row from a Database Control Method