Solved SQL Help

Discussion in 'Plugin Development' started by Geeky121, Mar 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Geeky121

    Code:java
    1. public void executeQuery(){
    2. Connection conn;
    3. String url = "jdbc:mysql://192.168.1.107:3306/players";
    4. try{
    5. conn = DriverManager.getConnection(url, "Test", "Password");
    6. PreparedStatement statement = conn.prepareStatement("INSERT INTO name (name) VALUES ('Test')");
    7. statement.executeQuery();
    8. } catch(Exception e){
    9. System.out.println("Error connecting to MySql Server.");
    10. }
    11. }
    12.  

    This method is called every time a player joins. But when it is called, it shows : "Error connecting to MySql Server." .

    I do have the SQL configured correctly but I still get the error.

    Can anyone please guide me on what I could be doing wrong?
     
  2. Offline

    rfsantos1996

    I belive tha username and password are case sensitive, and I'm not sure if this is the right order of arguments. (ok it is, I dont know how to fix it either lol)
     
  3. Offline

    nlthijs48

    Geeky121 Are you sure your sql server is reachable from another computer than localhost? Or does the sql server run at localhost?
     
  4. Offline

    Geeky121

    The SQL server runs on localhost. nlthijs48
     
  5. Offline

    nlthijs48

    Geeky121 Maybe try using the localhost address instead of your internal ip?
    Code:java
    1. jdbc:mysql://localhost:3306/players

    If you use your internal ip I think it connects differently, then it could get caught in the firewall or something like that.
     
  6. Offline

    Geeky121

    I got it working! The problem was this line:
    Code:java
    1. executeQuery()

    To:
    Code:java
    1. executeUpdate()


    Thanks for the help though!
     
Thread Status:
Not open for further replies.

Share This Page