Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. String url = null;
  2. try {
  3. if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
  4. Class.forName("com.mysql.jdbc.GoogleDriver");
  5. url = "jdbc:google:mysql://APP_ENGINE_ID:SQL_INSTANCE_NAME/DB_NAME?user=root";
  6. } else {
  7. Class.forName("com.mysql.jdbc.Driver");
  8. url = "jdbc:mysql://MY_IPV4_ADDRESS:3306/DB_NAME?user=root";
  9. }
  10. } catch (Exception e) {
  11. e.printStackTrace();
  12. }
  13.  
  14. try {
  15. //THIS is where it crashes
  16. conn = DriverManager.getConnection(url);
  17. try {
  18. String query = "SELECT * FROM UserTable";
  19. Statement st = conn.createStatement();
  20. ResultSet rs = st.executeQuery(query);
  21. while (rs.next())
  22. {
  23. //Code
  24. }
  25. st.close();
  26. } finally {
  27. conn.close();
  28. }
  29. } catch (SQLException e) {
  30. e.printStackTrace();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement