Заработало
This commit is contained in:
AidarKC
2025-12-18 15:37:28 +03:00
parent 4fb6b10a97
commit 1b1da19d3d
5 changed files with 58 additions and 84 deletions
@@ -42,7 +42,9 @@ public final class SolanaUsersDAO {
VALUES (?, ?, ?, ?, ?, ?)
""";
try (PreparedStatement ps = db.getConnection().prepareStatement(sql)) {
try (Connection c = db.getConnection();
PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, user.getLogin());
ps.setLong(2, user.getLoginId());
ps.setLong(3, user.getBchId());
@@ -66,9 +68,10 @@ public final class SolanaUsersDAO {
WHERE loginId = ?
""";
try (PreparedStatement ps = db.getConnection().prepareStatement(sql)) {
ps.setLong(1, loginId);
try (Connection c = db.getConnection();
PreparedStatement ps = c.prepareStatement(sql)) {
ps.setLong(1, loginId);
try (ResultSet rs = ps.executeQuery()) {
if (!rs.next()) return null;
return mapRow(rs);
@@ -76,7 +79,7 @@ public final class SolanaUsersDAO {
}
}
// добавь рядом со старым методом
// добавь рядом со старым методом
public SolanaUserEntry getByLogin(Connection c, String login) throws SQLException {
String sql = """
SELECT login, loginId, bchId, loginKey, deviceKey, bchLimit
@@ -100,9 +103,10 @@ public final class SolanaUsersDAO {
WHERE LOWER(login) = LOWER(?)
""";
try (PreparedStatement ps = db.getConnection().prepareStatement(sql)) {
ps.setString(1, login);
try (Connection c = db.getConnection();
PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, login);
try (ResultSet rs = ps.executeQuery()) {
if (!rs.next()) return null;
return mapRow(rs);
@@ -121,9 +125,10 @@ public final class SolanaUsersDAO {
List<SolanaUserEntry> result = new ArrayList<>();
try (PreparedStatement ps = db.getConnection().prepareStatement(sql)) {
ps.setString(1, prefix.toLowerCase() + "%");
try (Connection c = db.getConnection();
PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, prefix.toLowerCase() + "%");
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) result.add(mapRow(rs));
}
@@ -142,4 +147,4 @@ public final class SolanaUsersDAO {
rs.getObject("bchLimit") != null ? rs.getInt("bchLimit") : null
);
}
}
}