Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Get Current Date from MS Access in a Select Statement

843859Oct 1 2006 — edited Oct 1 2006
From a java method, I want to use JDBC to get the current date from MS Access. In Oracle I would do "select sysdate from dual", but I can't figure out how to do it in MS Access. Here are some of my attempts. I have a table in my Access db called PARM.
//        String sql = "SELECT '0', NOW() FROM PARM";
 //rs.next() is false
//        String sql = "SELECT NOW() AS CURR_DT FROM PARM";
//rs.next() is false
//        String sql = "SELECT DATE() AS CURR_DT FROM PARM";
//rs.next() is false
//        String sql = "SELECT NOW()";  
//StringIndexOutOfBoundsException: String index out of range: -1
//        String sql = "select { fn now() } from parm";
        String sql = "SELECT Date()"; 
//java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        ResultSet rs = stmt.executeQuery(sql);
        if (rs.next()) {
            return rs.getString(1);
        } else {
			return null;
		}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 29 2006
Added on Oct 1 2006
7 comments
326 views