Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = null;
- try {
- if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
- Class.forName("com.mysql.jdbc.GoogleDriver");
- url = "jdbc:google:mysql://APP_ENGINE_ID:SQL_INSTANCE_NAME/DB_NAME?user=root";
- } else {
- Class.forName("com.mysql.jdbc.Driver");
- url = "jdbc:mysql://MY_IPV4_ADDRESS:3306/DB_NAME?user=root";
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- //THIS is where it crashes
- conn = DriverManager.getConnection(url);
- try {
- String query = "SELECT * FROM UserTable";
- Statement st = conn.createStatement();
- ResultSet rs = st.executeQuery(query);
- while (rs.next())
- {
- //Code
- }
- st.close();
- } finally {
- conn.close();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement