Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Converting NUMBER, DATE and VARCHAR2 database fields from Resultset to variables?
Assume a database (e.g. Oracle) field is declared as
a) NUMBER (length=10) b) NUMBER (length=26) c) VARCHAR2 (length=1) d) VARCHAR2 (length=50) e) DATE
How do I retrieve the contents from these resultset fields and put it into a (numeric) java resp Date field?
For other field types it is already clear e.g.):
ResultSet rs = executeQuery(....);
...
int i = rs.getInt(1); // for INTEGER database fields String s = rs.getString(2) // for VARCHAR database fields (not VARCHAR2 !!) double d = rs.getDouble(3) // for DECIMAL database fields
How are the corresponding assign statements for NUMBER, VARCHAR2 and DATE ?
Sven Received on Wed Jan 26 2005 - 16:11:20 CST