My Bug report: JDBC-Driver produces wrong output.
От | Jan Thomae |
---|---|
Тема | My Bug report: JDBC-Driver produces wrong output. |
Дата | |
Msg-id | 00110212025700.00451@ramses обсуждение исходный текст |
Ответы |
Re: My Bug report: JDBC-Driver produces wrong output.]
|
Список | pgsql-bugs |
Hi, I had a look over the JDBC-Driver and was able to remove the bug. It seems, that the formatting of the timestamp caused the malfunction. I'd like to send you my modifications, since you might be interested in them: File: ResultSet.java Directory: src/interfaces/jdbc/org/postgresql/jdbc2 public Timestamp getTimestamp(int columnIndex) throws SQLException { String s = getString(columnIndex); if(s==null) return null; // This works, but it's commented out because Michael Stephenson's // solution is better still: // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Modification by Jan Thomae String sub = s.substring(s.length() - 3, s.length()-2); if (sub.equals("+") || sub.equals("-")) { s = s.substring(0, s.length()-3) + "GMT"+ s.substring(s.length()-3, s.length())+":00"; } // ------- // Michael Stephenson's solution: SimpleDateFormat df = null; // Modification by Jan Thomae if (s.length()>27) { df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz"); } else // ------- if (s.length()>21 && s.indexOf('.') != -1) { df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz"); } else if (s.length()>19 && s.indexOf('.') == -1) { df = new SimpleDateFormat("yyyy-MM-dd HH:MM:sszzz"); } else if (s.length()>19 && s.indexOf('.') != -1) { df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS"); } else if (s.length()>10 && s.length()<=18) { df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss"); } else { df = new SimpleDateFormat("yyyy-MM-dd"); } try { return new Timestamp(df.parse(s).getTime()); } catch(ParseException e) { throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s); } } Best regards, Jan Thomae -- ____________________________________________________________________ Jan Thomae jan@smb-tec.com SMB GmbH http://www.smb-tec.com
В списке pgsql-bugs по дате отправления: