A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java + MS Access
Cormac De Barra
Joined: Mar 13, 2006
Mar 13, 2006 11:22:00
I'm have a database with two fields Date(Date/Time) and amount(text) and I want to retrieve the Date With the following code.
connectionObject = DriverManager.getConnection(URL,username,password);
StatementObject = connectionObject.createStatement();
sqlQuery = "SELECT [Date] FROM Account;";
ResultSet statementResult = statementObject.executeQuery(sqlQuery);
DateFormat df = DateFormat.getDateInstance();
java.sql.Date d = statementResult.getDate(1);
String formattedDate = df.format(d);
but I get this error:
Problem with nullsent to
Problem is : [Microsoft][ODBC Microsoft Access Driver]Invalid character value for cast specification on column number 1 (Date)
Can anyone tell me what the problem is and how to fix it.
Joined: Feb 11, 2006
Mar 14, 2006 00:25:00
instead of java.sql.Date try
The java.sql.Date supports only date not Date + time.
java j2ee job interview questions with answers
Learn the core concepts and the key areas
Maximilian Xavier Stocker
Joined: Sep 20, 2005
Mar 15, 2006 00:45:00
As I told you already on the Sun JDBC forum using Date for the name of a column is a really bad idea. Don't use SQL reserved words (including data types) for column names.
I agree. Here's the link:
subject: Java + MS Access
How to see agenerated PreparedStatement
jdbc and insert date how
Issue with Date insertion
Dynamic SQl - PreparedStatement
Hibernate: native query to wrap the collection
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014