I'm trying to search a table in sql by timestamp using java and jdbc, but when I insert the timestamp into the query string I get a sytax error at the hour figure:
String queryString = "select " + tag + " from WATER_RUNTIME_VALUES
where Time_Stamp = 2015-06-150 8:58:00.0000000";
ResultSet rs = statement.executeQuery(queryString);
And here is the error:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '10'. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:792) at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:689) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:616) at bandon.scada.core.InitConn.calculateHourlyTotal(InitConn.java:58) at bandon.scada.core.InitConn.dbConnect(InitConn.java:36) at bandon.scada.core.InitConn.main(InitConn.java:24)