How to insert java Date object into Postgresql DATE cell?
When I do it my way, it's wrong:
Calendar date = Calendar.getInstance(); // wrong
Date date = new Date(); // wrong
String addRecord = "INSERT INTO " + GlobalFields.PACJENCI_TABLE +
"VALUES (" + date + ");";
stat.executeUpdate(addRecord)
I have no more ideas...
PS:
public static void CreatePacjenciTable()
{
try
{
Connection conn = DataBase.Connect();
try
{
Statement stat = conn.createStatement();
String createTable = "CREATE TABLE " + GlobalFields.PACJENCI_TABLE
+ "(dataUrodzenia DATE);";
stat.executeUpdate(createTable);
}
finally
{
conn.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}