TBrauwers TBrauwers - 3 months ago 17
Java Question

JDBC statement is not executed (No errors)

im working on a little Minecraft Plugin, im trying to insert data into the database with my DatabaseManager class but for some reason its not working. There are no error messages and the password and user name are correct. Also ive tried to insert the sql code manualy into the database and it works so there are no sql syntax errors. For me it seems like the statement is not executed for some reason but I cant find the failure. Below is the code of my class.

import java.sql.*;

* @author timob
public class DatabaseManager {
Connection conn = null;
Statement stmt = null ;
ResultSet result = null;

String user = "root" ;
String pass = "";

public ResultSet executeQuery(String query) throws SQLException{
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/metrocraft",user,pass);
stmt = conn.createStatement();
result = stmt.executeQuery(query);

}catch (Exception ex){
if(result != null)
if(stmt != null)
if(conn != null)
return result ;
//Metrocraft relevant code

public void addZone(double p1X , double p1Y,double p2X,double p2Y) throws SQLException{
String sql = "INSERT INTO `zones`( `p1X`, `p1Y`,`p2X`, `p2Y`) VALUES (" + p1X + ","+ p1Y+","+p2X+","+p2Y+"); ";


Use executeUpdate for database write operations

PreparedStatement stmt = conn.prepareStatement(query);
result = stmt.executeUpdate();