No Database selected when retrieving from mysql website

后端 未结 3 1991
半阙折子戏
半阙折子戏 2020-11-28 16:29

I have a mysql database that I am trying to retrieve from our website host (godaddy). I followed a format that seems to be right but it tells me that:

java.         


        
相关标签:
3条回答
  • 2020-11-28 16:29

    I had the same problem.

    Just run one more query (before your 'SELECT' statement) to connect to your database.

    First:

    sql = "USE <yourdatabase>";
    
    ResultSet rs = stmt.executeQuery(sql); 
    

    And after:

    sql = "SELECT * FROM item_master";
    
    rs = stmt.executeQuery(sql);
    
    0 讨论(0)
  • 2020-11-28 16:30

    Your URL for your database should include your database name. This is normally your URL followed by a "/DBNAME".

    String URL = "jdbc:mysql://localhost:3306/mydb";

    Where "mydb" is your database name.

    0 讨论(0)
  • 2020-11-28 16:51

    What is the value of DB_URL? As far as I am aware, the URL needs to be of the form: "WEBURL/DATABASENAME:PORT" Are you just trying to connect to the WEBURL, without specifying a DATABASE?

    0 讨论(0)
提交回复
热议问题