Hey, im using jdbc for my plugin and i ineed to return data from mysql in the chat. Any idea how to do it?
flevas Well to start, it may make things a bit easier if you use this: http://dev.mysql.com/downloads/connector/j/ Second, you'll need to write a MySQL query to pull the information out of the database. It's not too hard. Google it if you need to, you'll find plenty of information. After you get the data from the database, it's super simple to print it out in the chat. Let me know if you need any more help. Louis1234567890987654321 JDBC is a Java Database Connector. He's using it to connect to his MySQL database.
imporing data to mysql, reports specificaly. I want to readthem inside the server and not from the webpanel Yeah i know about queries, i've done it before with php also im successfuly importing data to mysql but i want to print them out now
Simply use a ResultSet. A resultset is generated after a query. Code: Statement s = connection.createStatement(); ResultSet rs = s.executeQuery("SELECT * FROM SOMETHING"); //so do something rs.close(); s.close();
Alright. Instead of typing it all out myself, I have found a thread that describes in great detail, and probably a little bit better than I could. Here's a link: Using MySQL In your plugin Hope it helps. After this, if you have any further questions, feel free to ask. flevas
Mine looks like this: Code:java try{ Connection conn = DriverManager.getConnection(this.url, this.user, this.pass); PreparedStatement query = conn.prepareStatement(""); query.executeUpdate(); query.close(); conn.close(); }
Code: Statement s = connection.createStatement(); ResultSet rs = s.executeQuery("SELECT * FROM SOMETHING"); if(rs.next()){ //rs.next() checks if there is more data next //something is in the query String str=rs.getString(databaseTableSomethingName); }else{ //things are not found } rs.close(); s.close(); If you want to manage multiple data, just loop through rs.next()