??? java.lang.String does not maps onto Oracle CHAR ???
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, December 21, 2001 03:05 AM

Thanks for the help :) I really appreciates your help. I've figured out the problem, after many trials. The problem lies with the mapping of Char on to String. Environment Oracle 8i (Oracle OCI8 Jdbc Driver) Java 1.3 JDBC 1.1 Current scenario is: 1. I have a prepared Statement which takes one argument(String) in where clause 2. When i execute it i dont get any result set - no error nothing ! just an empty set What i did (for test and trial): 1. I hard coded the values for place holders 2. prepared the statement 3. executed. it ran and returend ResultSet    More>>
Thanks for the help :)


I really appreciates your help.
I've figured out the problem, after many trials.
The problem lies with the mapping of Char on to String.

Environment

Oracle 8i (Oracle OCI8 Jdbc Driver)
Java 1.3
JDBC 1.1


Current scenario is:

1. I have a prepared Statement which takes one argument(String) in where clause

2. When i execute it i dont get any result set - no error nothing ! just an empty set


What i did (for test and trial):

1. I hard coded the values for place holders

2. prepared the statement

3. executed. it ran and returend ResultSet


Then...

1. I prepared the sql statement with a place holder of type String in where clause

2. Set the value of argument (to 4 char) using .setString and padded 16 spaces to it,

since database field is 20 char long.

3. executed the statement

4. It ran and returened ResultSet


Now, i hope you understand my problem.



I lookedup the java documentations and tutorails for mapping of datatypes. I found out that java
maps java.lang.String onto Char and Varchar2 automatically, therefore, one has not to convert from string to char[]. BUT this is not happening !



I am stuck here now... anyone can help me .

   <<Less

Re: ??? java.lang.String does not maps onto Oracle CHAR ???

Posted By:   Bernie_Acs  
Posted On:   Friday, December 21, 2001 06:37 AM

The datatype of choice would be VARCHAR2 versus CHAR. CHAR are always a fixed length for both reference and storage while VARCHAR2 would be variable for both reference and storage..


ALTER TABLE yourtable MODIFY ( thecolumn VARCHAR2(20) )

Re: ??? java.lang.String does not maps onto Oracle CHAR ???

Posted By:   Peter_Karlsson  
Posted On:   Friday, December 21, 2001 05:51 AM

Oracle datatype char(20) means exactly 20 characters, so I guess it will work with

select * from table where text='Peter             '
This will also work (I think):

select * from table where trim(text) = 'Peter';


I dont remember it its trim() or what to use (I dont use Oracle for the moment).


Remember that in the last command indexes can not be used.
About | Sitemap | Contact