Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.sql.Connection connection = null;
- java.sql.Statement statement = null;
- try {
- connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=");
- statement = connection.createStatement();
- String sql = "SELECT username, points FROM test";
- java.sql.ResultSet rs = statement.executeQuery(sql);
- while (rs.next()) {
- String name = rs.getString("username");
- int points = rs.getInt("points");
- plugin.getServer().broadcastMessage("Name: " + name + "; Points: " + points);
- }
- }catch(java.sql.SQLException e){
- e.printStackTrace();
- }finally{
- try {
- if(statement!=null){
- statement.close();
- }
- }catch(java.sql.SQLException e){
- e.printStackTrace();
- }
- }
- try {
- if (connection != null) {
- connection.close();
- }
- }catch(java.sql.SQLException e){
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement