Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://" + host + "/users?" + "user=" + user + "&password=" + pw );
- statement = connect.createStatement();
- resultSet = statement.executeQuery("select * from account");
- writeResultSet(resultSet);
- } catch (Exception e) {
- throw e;
- } finally {
- close();
- }
- Class.forName("com.mysql.cj.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://" + host + "/users?" + "user=" + user + "&password=" + pw );
- preparedStatement = connect.prepareStatement("insert into account values (default, ?, ?)");
- int dbAmount = 0;
- statement = connect.createStatement();
- resultSet = statement.executeQuery("select * from account");
- while (resultSet.next()) {
- dbAmount = resultSet.getInt("balance");
- }
- dbAmount += amount;
- preparedStatement.setInt(1, dbAmount);
- preparedStatement.setString(2, updatedAt);
- preparedStatement.executeUpdate();
- } catch (Exception e) {
- throw e;
- } finally {
- close();
- }
- Class.forName("com.mysql.cj.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://" + host + "/users?" + "user=" + user + "&password=" + pw );
- preparedStatement = connect.prepareStatement("update account set balance = ?, updatedAt = ? where id = 1");
- int dbAmount = 0;
- statement = connect.createStatement();
- resultSet = statement.executeQuery("select * from account");
- while (resultSet.next()) {
- dbAmount = resultSet.getInt("balance");
- }
- dbAmount += amount;
- preparedStatement.setInt(1, dbAmount);
- preparedStatement.setString(2, updatedAt);
- preparedStatement.setInt(3, 1);
- preparedStatement.executeUpdate();
- } catch (Exception e) {
- throw e;
- } finally {
- close();
- }
- java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/users?user=********&password=********
- at java.sql.DriverManager.getConnection(Unknown Source)
- at java.sql.DriverManager.getConnection(Unknown Source)
- at com.nsoft.serviceb.DbConnection.writeDataBase(DbConnection.java:39)
- at com.nsoft.serviceb.ServiceB.insertInDb(ServiceB.java:73)
- at com.nsoft.serviceb.ServiceB.lambda$receiveData$0(ServiceB.java:55)
- at com.rabbitmq.client.impl.recovery.AutorecoveringChannel$2.handleDelivery(AutorecoveringChannel.java:577)
- at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
- at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement