问题
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