Is it possible to save data in a mysql database using a method?


Hello community, I am an apprentice in java programming and I would like to know if it is possible to register to bd MySql using a public string method, adding the property of the data to be stored in a bd MySql, sorry for the question I've only been studying java for a month

asked by Sommer 07.10.2016 в 04:17

1 answer


To be able to make connections with BBDD in Java, use the JDBC driver.

1-Establish the connection 2-With the resulting object of that connection you perform any operation.

Here you have a tutor:


I hope this helps you:

public void insertoConsulta(Connection con,String consulta){
     Statement st=con.createStatement();
    //st.executeUpdate(consulta)   esto si es un insert por ejemplo
answered by 07.10.2016 в 12:44