Converting oracle.sql.timestamptz to java.sql.Timestamp

I'm trying to convert the systimestamp of the (Oracle) database to a java.sql.Timestamp

(Part of) the code I have for testing the process is:

try {
    conn = this.getConnection();
    Statement stmt = conn.createStatement();


    ResultSet rs = stmt.getResultSet();
    ResultSetMetaData rsm = rs.getMetaData();

    while( {
        TIMESTAMPTZ ts = (TIMESTAMPTZ) rs.getObject(1);
} catch (SQLException e) {

The output I get is:

class oracle.sql.TIMESTAMPTZ

and then an exception:
java.sql.SQLException: Conversion to Timestamp failed
at oracle.sql.Datum.timestampValue(
at com.sumawest.test.model.UnitTest.testTimezone(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at oracle.jdevimpl.junit.runner.TestRunner.doRun(
at oracle.jdevimpl.junit.runner.TestRunner.start(
at oracle.jdevimpl.junit.runner.TestRunner.main(
java.sql.SQLException: Conversion to Timestamp failed

Does anyone have an idea how I can solve this?


You could use the to_char function to convert it to a string and then use the value.

select to_char(systimestamp, 'IYYY-MM-DD HH24:MI:SS.FF TZD') as d from dual;

If you decompile the code you can see that you are calling the timestampValue method of the parent Datum class.

This directly throws the exception (no other code in the method). You need to call the timestampValue method of TIMESTAMPTZ itself passing a Connection.

Need Your Help

Rss in a WebView - iOS

iphone ios xcode rss webview

So I was doing a WebView for iOS on Xcode, everything is superfine but when i try to open an RSS url with the code below it doesn't work

tolower() function problems

c unix tolower

this is my example code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.