Read datas in MySQL Db

Discussion in 'Plugin Development' started by sacha220899, Jun 15, 2014.

Thread Status:
Not open for further replies.
  1. Hi,
    I want to read the kills from a player. For this, I have a MySQL Database, where I have already the kills. How can I now read them with my plugin?
    Lg
     
  2. Code:java
    1. Statement stmt;
    2.  
    3. Class.forName("com.mysql.jdbc.Driver");
    4. conn = DriverManager.getConnection("jdbc:mysql://IP?user=USER&password=PASSWORD");
    5. stmt = conn.createStatement();
    6. rs = stmt.queryUpdate("SELECT kills FROM DATABASE WHERE username='username'");
    7. while(rs.next) {
    8. //Do something with it
    9. }

    For instance, replace the USER with the login username and PASSWORD with login password, DATABASE with the tabel name and username with the user you want the kills from.
     
Thread Status:
Not open for further replies.

Share This Page