jBASE field type and JDBC sql data type
- Kim
- Topic Author
- Visitor
-
13 years 2 months ago - 13 years 2 months ago #11283
by Kim
jBASE field type and JDBC sql data type was created by Kim
hello all,
last time i submitted a topic titled "getting table list from jBASE via JDBC" and i fixed my problems with ambdev's help.
however, I got somehow strange results, so I'm asking your advice.
I got column information list of a jBASE table using JDBC.
The table was created by:
"CREATE TABLE member(id integer,name varchar(20))"
column information was extracted by using 2 functions:
ResultSet rs2 = dataBaseMeta.getColumns(null, null, "emp", null);
meta = rs2.getMetaData();
and java program printed output as below:
... COLUMN_NAME=RECID DATA_TYPE=0 TYPE_NAME=Z ... SQL_DATA_TYPE=null ...
... COLUMN_NAME=id DATA_TYPE=0 TYPE_NAME=LU ... SQL_DATA_TYPE=null ...
... COLUMN_NAME=name DATA_TYPE=0 TYPE_NAME=FC ... SQL_DATA_TYPE=null ...
I expected DATA_TYPE or SQL_DATA_TYPE comply to java.sql.Types, (value 4 for INTEGER and 12 for VARCHAR)
but their values are all 0 as you can see above.
However, fortunately, the function "getColumnType()" returned the expected value 4, and 12 as below:
ColumnName ColumnType ColumnTypeName
id 4 LU
name 12 FC
I wonder if jBASE JDBC field type supports all data types defined in java.sql.Types. (or some restrictions?)
I don't know where I can find information of Z and LU and FC.
So, questions are:
1. DATA_TYPE or SQL_DATA_TYPE doesn't work? Is the getColumnType function the only way to get column type?
2. where can i find information about JDBC sql field (data) types supported by jBASE?
3. where can i find information about Z, LU, FC ?
Please advise me.
regards,
last time i submitted a topic titled "getting table list from jBASE via JDBC" and i fixed my problems with ambdev's help.
however, I got somehow strange results, so I'm asking your advice.
I got column information list of a jBASE table using JDBC.
The table was created by:
"CREATE TABLE member(id integer,name varchar(20))"
column information was extracted by using 2 functions:
ResultSet rs2 = dataBaseMeta.getColumns(null, null, "emp", null);
meta = rs2.getMetaData();
and java program printed output as below:
... COLUMN_NAME=RECID DATA_TYPE=0 TYPE_NAME=Z ... SQL_DATA_TYPE=null ...
... COLUMN_NAME=id DATA_TYPE=0 TYPE_NAME=LU ... SQL_DATA_TYPE=null ...
... COLUMN_NAME=name DATA_TYPE=0 TYPE_NAME=FC ... SQL_DATA_TYPE=null ...
I expected DATA_TYPE or SQL_DATA_TYPE comply to java.sql.Types, (value 4 for INTEGER and 12 for VARCHAR)
but their values are all 0 as you can see above.
However, fortunately, the function "getColumnType()" returned the expected value 4, and 12 as below:
ColumnName ColumnType ColumnTypeName
id 4 LU
name 12 FC
I wonder if jBASE JDBC field type supports all data types defined in java.sql.Types. (or some restrictions?)
I don't know where I can find information of Z and LU and FC.
So, questions are:
1. DATA_TYPE or SQL_DATA_TYPE doesn't work? Is the getColumnType function the only way to get column type?
2. where can i find information about JDBC sql field (data) types supported by jBASE?
3. where can i find information about Z, LU, FC ?
Please advise me.
regards,
Last edit: 13 years 2 months ago by Kim.
Please Log in or Create an account to join the conversation.
- ambdev
- Offline
- Junior Member
-
Less
More
- Posts: 30
- Thank you received: 5
13 years 2 months ago #11303
by ambdev
Replied by ambdev on topic Re: jBASE field type and JDBC sql data type
The first thing that you should keep in mind is: "The jBASE JDBC 2.0 Driver implements a subset of the JDBC 2.0 API" as stated in the official documentation at www.jbase.com/r5/knowledgebase/manuals/3.../j5_JDBC_DEVELOP.htm
As far as I know the only place where you can find the supported sql types is in a table called SYS_TYPE_INFO, this table should be anywhere in your TAFC (jBase 5.2) installation path. Take a look at the "jBASE JDBC Driver" guide to know more about the table.
Here a sample of the table contents, yours may be different.
BIGINT
BIT *
CHAR *
DOUBLE *
FLOAT *
INTEGER *
LONGVARBINARY
LONGVARCHAR *
NUMERIC *
TINYINT *
VARBINARY
VARCHAR *
Unfortunately only the ones marked with an asterisk are well supported, at least in my experience and with the drivers that I've had access to. In fact, you can use almost all java.sql.Types, but when reading meta-data or using getXXXX() methods it's going to return exceptions all the time; to be safe you should use getString() method.
Now the answers to your questions:
1. DATA_TYPE or SQL_DATA_TYPE doesn't work? Is the getColumnType function the only way to get column type?
- YES
2. where can I find information about JDBC sql field (data) types supported by jBASE?
- SYS_TYPE_INFO table
3. where can i find information about Z, LU, FC ?
- I could not find any useful information about this identifiers, but I guess it's not that important
As far as I know the only place where you can find the supported sql types is in a table called SYS_TYPE_INFO, this table should be anywhere in your TAFC (jBase 5.2) installation path. Take a look at the "jBASE JDBC Driver" guide to know more about the table.
Here a sample of the table contents, yours may be different.
BIGINT
BIT *
CHAR *
DOUBLE *
FLOAT *
INTEGER *
LONGVARBINARY
LONGVARCHAR *
NUMERIC *
TINYINT *
VARBINARY
VARCHAR *
Unfortunately only the ones marked with an asterisk are well supported, at least in my experience and with the drivers that I've had access to. In fact, you can use almost all java.sql.Types, but when reading meta-data or using getXXXX() methods it's going to return exceptions all the time; to be safe you should use getString() method.
Now the answers to your questions:
1. DATA_TYPE or SQL_DATA_TYPE doesn't work? Is the getColumnType function the only way to get column type?
- YES
2. where can I find information about JDBC sql field (data) types supported by jBASE?
- SYS_TYPE_INFO table
3. where can i find information about Z, LU, FC ?
- I could not find any useful information about this identifiers, but I guess it's not that important
Please Log in or Create an account to join the conversation.
- Kim
- Topic Author
- Visitor
-
13 years 2 months ago #11304
by Kim
Replied by Kim on topic Re: jBASE field type and JDBC sql data type
Dear ambdev,
Thanks to your attention and help.
And to conclude, until now what i have done is:
1. correcting environment setup : especially JEDIFILENAME_MD
2. fixing java src code.
at first, perform a SQL SELECT query.
and next, get metadata using getMetaData()
and next, get column type using getColumnType()
that's it.
Something strange is that SELECT query must be performed before getting metadata.
if try to get metadata before select, we cannot get correct column type.
the example code of "JDBC API reference" (found in www.jbase.com/r5/knowledgebase/manuals/3.../j5_JDBC_DEVELOP.htm) shows this.
besides, unfortunately i couldn't find SYS_TYPE_INFO table on my jBase5.2/JDBC2.0 installation.
but your sample contents made me to grasp it.
Regards,
Thanks to your attention and help.
And to conclude, until now what i have done is:
1. correcting environment setup : especially JEDIFILENAME_MD
2. fixing java src code.
at first, perform a SQL SELECT query.
and next, get metadata using getMetaData()
and next, get column type using getColumnType()
that's it.
Something strange is that SELECT query must be performed before getting metadata.
if try to get metadata before select, we cannot get correct column type.
the example code of "JDBC API reference" (found in www.jbase.com/r5/knowledgebase/manuals/3.../j5_JDBC_DEVELOP.htm) shows this.
besides, unfortunately i couldn't find SYS_TYPE_INFO table on my jBase5.2/JDBC2.0 installation.
but your sample contents made me to grasp it.
Regards,
Please Log in or Create an account to join the conversation.
Time to create page: 0.038 seconds