Code:java Connection con = null;Statement stmt = null;ResultSet result = null;try{ con = DriverManager.getConnection("jdbc:mysql://iport/database"); stmt = con.createStatement(); result = stmt.executeQuery("SELECT * FROM table"); if(result.next()) { int columnNumber = 0; int someNumber = result.getInt("columnname"); String someString = result.getString(columnNumber); } else { // Empty ResultSet, aka no columns }}catch (SQLException ex){ this.getLogger().warning("An SQL exception occurred: "+ex.getMessage());}finally{ if(result != null) { result.close(); } if(stmt != null) { stmt.close(); } if(con != null) { con.close(); }} A very basic snippet. I am not sure about the url (if it is "jdbc:mysql://")
fireblast709 You are correct on the URL. If possible, make sure you run your MySQL in a separate thread so that it doesn't lag the game.
fireblast709 Should the Connection not be closed after the query is pulled ( } finally {) ? Or is this automaticly done? con.close()
One question left. fireblast709 Should stmt and result be closed as well? or this will close as well when con is closed?
you are all right. Though in Java 7 this is not needed anymore (since they have try-with-resources and auto closable resources). But as we have 1.5/1.6 as standard, they still need to be closed manually