Re: CachedRowSetImpl.getTimestamp() throwing exception
- From: itreflects@xxxxxxxxx
- Date: 17 Dec 2006 17:52:30 -0800
Thanx for sharing code. Yeah, i think oracle guys fixed that bug in new
driver version. However there is an alernate solution to the problem if
u r still using 9.2* version of drivers i.e oracle does its own
implementation CachedRowSet (look for OracleCachedRowSet in oro*.jar
file shipped with installation, sorry can't remember exact jar file
name) and that takes care of TimeStamp related issue.I was using Sun
implementation of CachedRowSet with Oracle db, hence faced that
exception.
bjorn.ahl@xxxxxxxxx wrote:
I Tested that with oracle Jdbc version 10.2.0.1 and gott it to work. :D
My Test code
import java.sql.Timestamp;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.sun.rowset.CachedRowSetImpl;
import java.sql.Date;
public class CachedRowSetImplTest {
public static void main(String args []) {
CachedRowSetImplTest runMe = new CachedRowSetImplTest();
}
/** Creates a new instance of CachedRowSetImplTest */
public CachedRowSetImplTest() {
Connection conn;
try {
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
} catch (SQLException ex) {
ex.printStackTrace();
}
try {
conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ora10gr2",
"scott", "tiger");
} catch( Exception e ) {
System.out.println( "error connecting" );
e.printStackTrace( );
return;
}
try {
// Create a Statement
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select ename, hiredate
from emp");
CachedRowSetImpl crs = new CachedRowSetImpl();
crs.populate(rset);
System.out.print("test");
while (crs.next()) {
//java.sql.TimeStamp =
Timestamp myTimeStamp = crs.getTimestamp("HIREDATE");
// EOD_DATE coulmn is of type DATE, this line is throwing
System.out.println(crs.getTimestamp("HIREDATE"));
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
.
- References:
- Re: CachedRowSetImpl.getTimestamp() throwing exception
- From: bjorn . ahl
- Re: CachedRowSetImpl.getTimestamp() throwing exception
- Prev by Date: Re: Problem with jdbc, RowSet and Oracle
- Next by Date: Re: JDBC Connection returns wrong status
- Previous by thread: Re: CachedRowSetImpl.getTimestamp() throwing exception
- Next by thread: Free Blog hosting for Java people at www.brainjava.com
- Index(es):
Relevant Pages
|
|