help with JDBC

E

Ebrahim

hi guys .. I am using Oracle : JDBC driver to connect to an oracle
server . I am reading the cols from the db into a ResultSet . When I
program in Eclipse I can read the values from rs.getString(col_name)(
the resultset object ) . But the same code does not work when I run my
code on my server - Tomcat .
It gives the Exception ResultSet.next() was not called .
It does not make any sense ... coz it connects fine to the db fine but
does not read any values ...
BEsides why should ResultSet.Next() be called in the first place ??
(even though I do call it from my program ) Becoz I am reading only 1
row from the DB at a time so why call rs.next() .

S O M E O N E P L S E X P L A I N ????????????????
 
S

Steve Cassidy

Ebrahim said:
hi guys .. I am using Oracle : JDBC driver to connect to an oracle
It gives the Exception ResultSet.next() was not called .
BEsides why should ResultSet.Next() be called in the first place ??

rs.next() reads a row from the database into the ResultSet. When you first
create a ResultSet with statement.executeQuery() or similar, the cursor into
the ResultSet is initially positioned at the start, before the first row.
Your first call to rs.next() reads the first row - you have to call it even
if your query returns only one row. Until you've called this you can't
retrieve any values, as there aren't any loaded to retrieve.
 
E

Ebrahim

Steve Cassidy said:
rs.next() reads a row from the database into the ResultSet. When you first
create a ResultSet with statement.executeQuery() or similar, the cursor into
the ResultSet is initially positioned at the start, before the first row.
Your first call to rs.next() reads the first row - you have to call it even
if your query returns only one row. Until you've called this you can't
retrieve any values, as there aren't any loaded to retrieve.

thx for clearing that doubt !!!

could you also help me with the following :
i need to enter values into my Oracle db in chinese . For this I need
to set up the Oracle DB in chinese . Since I work for a company , they
might not allow me to change the charset for the entire database to
UTF-8 but rather only for a specific schema . Can you help me with
this ?? Do you know of any other way by which I can enter data in
Chinese/Japanese in an ORacle DB ??

Ebrahim B
 
S

steve

thx for clearing that doubt !!!

could you also help me with the following :
i need to enter values into my Oracle db in chinese . For this I need
to set up the Oracle DB in chinese . Since I work for a company , they
might not allow me to change the charset for the entire database to
UTF-8 but rather only for a specific schema . Can you help me with
this ?? Do you know of any other way by which I can enter data in
Chinese/Japanese in an ORacle DB ??

Ebrahim B

O.K here we go again.
you need to read up on oracle multi character support, it has improved since
UTF-8

(see the rather long running thread i18n'ed characters set in DBMS and
tables) in this new group.

you can support any multi byte language, chinese/japanese in an oracle
database.

if using oracle , YOU MUST ensure your Schema represents the character
encoding data you are entering into it. ( yes you CAN get away with sticking
multibyte data into a normal clob/varchar2)


but be aware on pl/sql string functions, if you use the wrong encoding ( by
sticking multibyte into single byte tablespace) you will SERIOUSLY mess up
the string functions , and the text indexing functions. if you heed to get 1
character or a bunch of characters.

also oracle will try to do character tanslation between the database & the
client.

however if you like to live dangerously, loose upgradeability and don't mind
loosing string indexing ( or your job):

you can try the following:

1. get your java app to input ALL the asian text.
Build a binary storage area.
delimit the asian text (somehow), concat the resulting Objects
insert your "asian" Objects into a binary staging area.

write the staging area to oracle & store it in a BLOB ( binary large object)
( oracle will not index or try to do character translation, do not use a
CLOB)


when you need the asian text , get the BLOB from the database, unpack the
data, & display it on your screen.

( do not try to get smart , and realize that you can use java in the database
to "serialize objects", then try to call the server code from the client
java, to serialize the data , to & from the database, if you do the overhead
will buy your database)

Be aware that you are fooling yourself & the database , by doing the above.
( if you have to add fields/remove fields from your data, or make fields
longer/smaller, then you better be sure your packing/unpacking routines are
smart enough)

steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top