- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下 SQL 查询:
SELECT `Activity`.`userid` , `Goal`.`goalid` , `Goal`.`activityid` , `Goal`.`exercise` , `Exercise`.`name` , `Goal`.`target` , `ActivityData`.`dataid` , `ActivityData`.`current` , MAX( `ActivityData`.`timestamp` ) AS `timestamp`
FROM `Goal`
INNER JOIN `Activity` ON `Activity`.`activityid` = `Goal`.`activityid`
INNER JOIN `Exercise` ON `Exercise`.`exerciseid` = `Goal`.`exercise`
INNER JOIN `ActivityData` ON `ActivityData`.`activityid` = `Goal`.`activityid`
WHERE `Activity`.`userid` =100005545413982
GROUP BY `gymbuddy`.`Goal`.`activityid`;
上面的查询在 phpMyAdmin 中有效,但是当我使用 PreparedStatement 运行它时,它会给我以下堆栈跟踪。
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY `gymbuddy`.`Goal`.`activityid`' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
at com.mathanv.gb.dao.BuddyDao.getAllBuddyGoals(BuddyDao.java:387)
at com.mathanv.gb.controller.BuddyController.doPost(BuddyController.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
这些是数据库属性:
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:8889/gymbuddy?allowMultiQueries=true
不确定为什么要这样做!帮助!
编辑:我正在使用 preparedStatement 生成用户 ID。
WHERE `gymbuddy`.`Activity`.`userid` =?
ps.setLong(1, buddy.getUserID());
编辑:(请求)方法与 PreparedStatement。
public JSONObject getAllBuddyGoals(Buddy buddy){
try {
PreparedStatement ps = connection.prepareStatement(GET_ALL_BUDDY_GOALS);
ps.setLong(1, buddy.getUserID());
JSONObject response = new JSONObject();
response.put("action", "getAllBuddyGoals");
response.put("success", 1);
response.put("error", 0);
response.put("userid", buddy.getUserID());
JSONArray goals = new JSONArray();
ResultSet rs = ps.executeQuery();
while(rs.next()){
JSONObject goal = new JSONObject();
goal.put("goalid", rs.getLong("goalid"));
goal.put("activityid", rs.getLong("activityid"));
goal.put("exercise", rs.getString("name"));
goal.put("target", rs.getDouble("target"));
goal.put("max", rs.getDouble("current"));
goals.add(goal);
}
response.put("goals", goals);
return response;
} catch (SQLException e) {
e.printStackTrace();
}
JSONObject error = new JSONObject();
error.put("action", "getAllBuddyGoals");
error.put("success", 0);
error.put("error", 1);
error.put("error_msg", "error processing request, please contact admin.");
return error;
}
最佳答案
您可能需要检查好友 ID 值和术语组之间是否存在实际空格。如果你读到 Java 抛出的错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the
right syntax to use near 'BY `gymbuddy`.`Goal`.`activityid`' at line 1
Mysql 错误通常发生在错误提示之前。我的猜测是您正在执行的查询在 100005545413982 和 GROUP 之间缺少一些空格,可能是这样的:
WHERE `Activity`.`userid` =100005545413982GROUP BY `gymbuddy`.`Goal`.`activityid`;
关于mysql - SQL 查询在 phpMyAdmin 中有效,但在 Java 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15954287/
在 phpMyAdmin 的设置过程中,创建了一个 phpMyAdmin 用户,当我查看 phpMyAdmin 数据库权限时,我可以看到该用户。哪个 PHP 文件存储了该用户的密码? 最佳答案 保罗,
如何删除 phpMyAdmin 中的框架? 最佳答案 打开/usr/share/phpmyadmin/index.php(它在我的 Ubuntu 机器上)。不要忘记使用 sudo 或成为 root。
我读过官方文档说 phpMyAdmin 应该安装在 Web 服务器的文档根目录中。 我想问一下我是否必须为我拥有的每个 DocumentRoot 放置一个 phpMyAdmin,或者是否有一个很好的解
在遵循 youtube 上的 2019 教程后,无法在 virtualbox 上滚动的 kali linux 上安装 phpmyadmin, 尝试过 sudo apt-get install phpm
请帮忙,我总是在经历所有这些事情时遇到麻烦。当我只需要 phpmyadmin 有一个登录表单时,我就可以输入密码和用户名。 我不需要本文档中包含的所有内容。是否有针对初学者的教程,介绍如何在 phpm
标题几乎总结了我的问题。 我只想了解如何禁用远程登录到我的 phpmyadmin。 我宁愿只能从本地主机登录到 phpmyadmin。 最佳答案 编辑 /etc/phpmyadmin/apache.c
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我创建了具有两列(id、name)的数据库(产品)表项目,并且我向该列添加了值,然后显示此错误 Warning in .\libraries\DisplayResults.php#869 A non
我想将 SELECT 查询的结果导出为有效的 SQL INSERTS,并将其导入到另一个数据库中(某些记录被意外删除)。通常我会使用 PHPMyAdmin 的导出功能,但 PHPMyAdmin 在其中
当我尝试从 phpMyAdmin 导出数据库时出现错误。 请引用下面的截图。 我不知道这个问题是怎么发生的。 最佳答案 我遇到了同样的问题,我通过增加 php.ini 中 'max_input_var
无法访问 phpMyAdmin。我的 wampserver 版本是 2.2,使用 Windows 7。 localhost/phpmyadmin/ 当我打开它。 Internet Explorer 打
在我的工作中,我有 phpmyadmin 要使用的 SQL 数据库(本地和服务器上) 烦人的问题是,当我修改本地数据库结构(列、关系、新表)时,我不得不在服务器数据库上再次重做修改,因为当我备份本地数
我不喜欢 phpMyAdmin 中新的 AJAX 风格的导航树,我想将其更改为旧的。是否有一些我可以更改的配置指令? 旧版本:3.3.7 新版本:4.0.4 两者中的原始主题。 最佳答案 没有配置指令
我正在尝试更改 phpmyadmin 中的日期格式。我无法更改格式 我想将格式更改为 dd-mmm-yyyy。如何更改日期格式。请帮我解决它.. 最佳答案 您可以使用 phpMyAdmin 的 bro
我想在 PhpMyAdmin 中为包含此文本的所有字段更改文本“pelecard”。表名是 sales_flat_order_payment。我怎么能做到这一点? 谢谢你 最佳答案 SQL 是什么?
在远程 ubuntu 18 服务器上,当从其中一个表中打开 phpmyadmin 中的数据时,它会显示警告和弹出窗口(如 https://imgur.com/a/b5HGGV0 ),这是非常缺乏的..
默认情况下,phpMyAdmin 中的“主题”选项仅影响主题设置更改的浏览器的主题(可能存储在 cookie 中?)。如何将特定主题设置为所有用户的默认主题? 最佳答案 可以从 phpMyAdmin
我的表有全文列。如何设置列的默认宽度?我知道它在 index.php 页面顶部有完整/部分文本按钮...如何永久设置该值? 谢谢! 最佳答案 有一个名为 LimitChars 的配置值:http://
我是 mysql 的新手,所以我正在使用 phpmyadmin 在数据库中创建表。我有枚举类型的字段制造商,可能的值为“manufacturer1”,“manufacturer2”,... 我选择了
有谁知道是否或如何增加phpMyAdmin 中的导入大小限制?目前我的服务器限制为 50MB。 请注意,这与 php.ini 中的 upload_max_filesize 不同。该值设置为 2MB。
我是一名优秀的程序员,十分优秀!