|
-
December 15th, 2011, 09:17 AM
#1
Java ResultSet and column database problem
Hi all of you!
I am new in this site and I hope any of you could help me.
This is my problem:
I have a mysql database NO INNODB.
There is a table which contains some columns and one of these is a Time type column.
To retrieve informations from that table in my java method, I have created a ResultSet rs in which I have the result of my query:
PreparedStatement stmtOrari = mysqlCon.prepareStatement("SELECT * FROM [tableName] where id="+id);
ResultSet rs = stmtOrari.executeQuery();
The problem is that in the database there are no restriction on column and data values, so in that Time column I found values like '51:50:24' and other greater than '23:59:59'.
If I try to retrieve values from the resultSet using rs.getTime("columnName"), the method crashes and launch an SqlException: "Illegal hour value '51' for java.sql.Time type in value '51:50:24."
My first reaction was to use the getString method on that field of the resultSet rs trying to convert the data type on a String object to solve the problem: String s = rs.getString("columnName");
but I had the same exception.
Any of you could help me to solve this problem?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|