Skip to content

SELECT命令与JDBC使用#190

Open
zdmhahaha wants to merge 2 commits into
masterfrom
zdmgo
Open

SELECT命令与JDBC使用#190
zdmhahaha wants to merge 2 commits into
masterfrom
zdmgo

Conversation

@zdmhahaha

Copy link
Copy Markdown
Contributor
  • 这个PR解答了当前仓库中的题目(机器人会自动判题并合并当前PR)
  • 这个PR修复了当前仓库中的一些代码缺陷(机器人不会判题,而是由管理员来处理当前PR)

@hcsp-bot

Copy link
Copy Markdown
Contributor

🎉 感谢提交Pull Request!请稍等片刻,我们已经将其提交到CI进行检查,一旦有结果会立即通知您!

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应使用 '.*' 形式的导入 - java.sql.* 。

public static int countUsersWhoHaveBoughtGoods(Connection databaseConnection, Integer goodsId) throws SQLException {
return 0;
PreparedStatement statement = databaseConnection.prepareStatement("select count(distinct user_id) from `order` where goods_id = ?");
statement.setInt(1,goodsId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

',' 后应有空格。

public static List<User> getUsersByPageOrderedByIdDesc(Connection databaseConnection, int pageNum, int pageSize) throws SQLException {
return null;
PreparedStatement statement = databaseConnection.prepareStatement("select id, name, tel ,address from `user` ORDER BY ID DESC limit ?,?");
statement.setInt(1,pageSize * (pageNum - 1));//2 2,2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

',' 后应有空格。
';' 后应有空格。

return null;
PreparedStatement statement = databaseConnection.prepareStatement("select id, name, tel ,address from `user` ORDER BY ID DESC limit ?,?");
statement.setInt(1,pageSize * (pageNum - 1));//2 2,2
statement.setInt(2,pageSize);//2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

',' 后应有空格。
';' 后应有空格。

List<GoodsAndGmv> list = new ArrayList<>();
while (resultSet.next()) {
GoodsAndGmv goodsAndGmv = new GoodsAndGmv();
goodsAndGmv.goodsId= resultSet.getInt(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'=' 前应有空格。

while (resultSet.next()) {
Order order = new Order();
order.id = resultSet.getInt(1);
order.userName= resultSet.getString(2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'=' 前应有空格。

while (resultSet.next()) {
Order order = new Order();
order.id = resultSet.getInt(1);
order.userName= resultSet.getString(2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'=' 前应有空格。

@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 084db95 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

public static List<User> getUsersByPageOrderedByIdDesc(Connection databaseConnection, int pageNum, int pageSize) throws SQLException {
return null;
PreparedStatement statement = databaseConnection.prepareStatement("select id, name, tel ,address from `user` ORDER BY ID DESC limit ?,?");
statement.setInt(1, pageSize * (pageNum - 1));//2 2,2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

';' 后应有空格。

return null;
PreparedStatement statement = databaseConnection.prepareStatement("select id, name, tel ,address from `user` ORDER BY ID DESC limit ?,?");
statement.setInt(1, pageSize * (pageNum - 1));//2 2,2
statement.setInt(2, pageSize);//2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

';' 后应有空格。

@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 f2de814 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

@hcsp-bot hcsp-bot mentioned this pull request Nov 19, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants