Testing Queries and Formmating dates in Apache Derby

扶醉桌前 提交于 2019-12-11 21:13:31

问题


I'm new to java db, before this I've always used Microsoft SQL for database programming. I used SQL Express and Management Studio for database testing and creation.

Now i want to use java db instead, i'm confused about some things about Derby:

  • What platform i should use to test my database queries as i used Management Studio for SQL.
  • Secondly, i'm confused about formatting Dates in Derby as i used Set DateFormat function in SQL to format dates. I'm using TimeStamp Datatype and i want my date to be stored in the following format in the database: "Wednesday, August 2014, 11:30 PM"

Please Help!


回答1:


Derby has an interactive sql client called ij, that can be used to test queries. Look for it in the documentation.

Timestamps are not stored in a particular format. You decide the format when you retrieve the value from the database. E.g.:

CREATE TABLE TIMES(THE_TIME TIMESTAMP);

...

java.sql.Timestamp x = rs.getTimestamp(...);

java.sql.Timestamp is a subclass of java.util.Date and you are free to format the value as you want.

To store a value you just create a java.sql.Timestamp from your input in whatever format it is.



来源:https://stackoverflow.com/questions/25449472/testing-queries-and-formmating-dates-in-apache-derby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!