sysdate()
我正在从 android 设备发送到服务器字符串。问题是代码没有向 mysql 数据库插入任何内容。列first
是DATETIME
。我正在使用 mysql 工作台,当我输入INSERT INTO test (first) VALUES (sysdate());
工作台时,它可以工作。
<%
String t = request.getParameter("time");
Connection connection = null;
PreparedStatement pstatement = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
int updateQuery = 0;
if (t != null) {
if (t != "" ) {
try {
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st = connection.createStatement();
String queryString1 = "INSERT INTO test (first) VALUES (?)";
pstatement = connection.prepareStatement(queryString1);
pstatement.setString(1, t);
updateQuery = pstatement.executeUpdate();
if (updateQuery != 0) {
response.setStatus(400);
}
} catch (Exception ex) {
out.println(ex);
} finally {
pstatement.close();
connection.close();
}
}
}
%>