MySQL Forums
Forum List  »  Newbie

Re: Automatic timezone assigned to inserted value
Posted by: Max Mattsson
Date: June 11, 2021 10:59AM

I have my server fetch and insert data into my sql database. These are the methods for doing that.

The result of show create table
CREATE TABLE `sensor` (
`Timestamp` date NOT NULL DEFAULT curdate(),
`Value` double NOT NULL,
`SensorType` int(11) NOT NULL,
`SensorID` int(11) NOT NULL,

The command i use to insert rows:

public int insert(double value, int sensorType, int sensorID) throws SQLException {
String insertString = String.format(Locale.US,"INSERT INTO sensor (Value, SensorType, SensorID) VALUES (%f , %d, %d);",
value, sensorType, sensorID);
return statement.executeUpdate(insertString);

the query to fetch rows:

public List<Data> get(int sensorID) throws SQLException {
String getString = String.format("SELECT * FROM sensor WHERE SensorID = %d", sensorID);
ResultSet resultSet = statement.executeQuery(getString);
List<Data> dataList = new LinkedList<>();
while ( {
Data newData = new Data();
read(resultSet, newData);
return dataList;

While doing this i came across an error message when clicking the 'wrench icon' to the right of my table. When i clicked it i got an error message saying;
"Error Parsing DDL for 'arduinodb'.'sensor'
There was an error while parsing the DDL retrieved from this server. Do you want to view the DDL or cancel processing it?"
When i click "View DDL" it shows the create table query as i posted in the beginning of this message. And it shows an error on line 5 which is "`Timestamp` date NOT NULL DEFAULT curdate()". It says that curdate() is not valid at this position. How do i make that correct because i cant change it in this query as it is just the create table query.

Options: ReplyQuote

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.