Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
  2. your SQL syntax; check the manual that corresponds to your MySQL server version
  3. for the right syntax to use near 'usage = 6000 where user_id = 1 and api_id = 1'
  4. at line 1
  5. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  6. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
  7. orAccessorImpl.java:39)..
  8.  
  9. int u_id=1;
  10. int a_id=1;
  11.  
  12. String url = "jdbc:mysql://localhost:3306/new_db";
  13. String driver = "com.mysql.jdbc.Driver";
  14. String userName = "root";
  15. String password = "1234";
  16. int APIusage = 0;
  17.  
  18.  
  19. try {
  20. Class.forName(driver).newInstance();
  21.  
  22. Connection conn = DriverManager.getConnection(url, userName, password);
  23. String query = "update api_consume set usage = ? where user_id = ? and api_id = ?";
  24. PreparedStatement preparedStmt = conn.prepareStatement(query);
  25. preparedStmt.setInt(1, 6000);
  26. preparedStmt.setInt(2, u_id);
  27. preparedStmt.setInt(3, a_id);
  28.  
  29. // execute the java preparedstatement
  30. preparedStmt.executeUpdate();
  31.  
  32. conn.close();
  33. }
  34. catch (Exception e) {
  35. e.printStackTrace();
  36. }
  37.  
  38. String query = "update api_consume set `usage` = ? where user_id = ? and api_id = ?";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement