*
The moose likes JDBC and the fly likes Some problem with JDBC - Oracle when using awt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Some problem with JDBC - Oracle when using awt" Watch "Some problem with JDBC - Oracle when using awt" New topic
Author

Some problem with JDBC - Oracle when using awt

Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
hi
Please help me out about the following.
Everything is going smoothly except Scrollable
ResultSets(JDBC 2). Add(insert), Delete, Edit(update),
MoveNext are perfectly working. But Moving to the
previous, last, first records is not successful yet.
Traditional JDBC does not support these things. JDBC 2
supports but I'm facing problems as follows :
by default ResultSet's type is TYPE_FORWARD_ONLY so
while creating Statement object I used JDBC 2's
createStatement method which takes 2 parameters as
ReesultSet's type and concurrency.
.....
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("select * from
ORA_StudentMaster");
.....
still SQLException was fired saying that Result set is
TYPE_FORWARD_ONLY. How can it be? I have set it to
TYPE_SCROLL_INSENSITIVE. So for cross checking I used
methods of DatabaseMetaData class :
supportsResultSetType ans supportsResultSetConcurrency
passing appropraite arguments, these methods return
boolean value.
System.out.println(con.getMetaData().supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY)); ///~ true
For both ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY i got answer true. After
this confirmation I checked as follows :
.....
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
System.out.println(stmt.getResultSetType()); ///~1
ResultSet rs = stmt.executeQuery("select * from
ORA_StudentMaster");
System.out.println(stmt.getResultSetType()); ///~2
.....
In the statement ///~1 1004 was printed and in
statement ///~2 1003 was printed. Well, WHAT WILL BE
THE SOLUTION FOR THIS?
I'm using Oracle8i, jdk1.3 and System DSN of Oracle
ODBC Driver.
Kajol
Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
Hi Guys,
No reply .. I am really in need of an answer as I have got stuck. Please reply asap.
Kajol
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Hmmm... that might be because you posted it to the Swing / JFC / AWT forum, and your problem really has to do with JDBC... I'll move this to a more appropriate forum, so it will have a better chance of being answered.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Kajol:
There are some limitations to the Oracle Drivers that can be found here ( scroll down to "Result Set Limitations" ).
This is what you'll find:
To produce an updatable result set:
A query can select from only a single table and cannot contain any join operations.
In addition, for inserts to be feasible, the query must select all non-nullable columns and all columns that do not have a default value.
A query cannot use "SELECT * ". (But see the workaround below.)
A query must select table columns only. It cannot select derived columns or aggregates such as the SUM or MAX of a set of columns.
To produce a scroll-sensitive result set:
A query cannot use "SELECT * ". (But see the workaround below.)
A query can select from only a single table.
Workaround
As a workaround for the "SELECT *" limitation, you can use table aliases as in the following example:
SELECT t.* FROM TABLE t ...
--------------------------------------------------------------------------------
Hint:
There is a simple way to determine if your query will probably produce a scroll-sensitive or updatable result set: If you can legally add a ROWID column to the query list, then the query is probably suitable for either a scroll-sensitive or an updatable result set. (You can try this out using SQL*Plus, for example.)
--------------------------------------------------------------------------------

Hope this solves your problem,
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some problem with JDBC - Oracle when using awt