I have this code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class DBConntest {
public static void main(String[] args) {
try {
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/?user=root&useSSL=false", "root", "root");
System.out.println("Connection succes!");
Statement stmt = conn.createStatement();
String query1 = "USE test; insert into dbtester(name,age,email) values ('Aram',18,'[email protected]');";
stmt.executeUpdate(query1);
}
catch (Exception e){
System.err.println(e);;
}
}
}
I use Eclipse, and after run it return this error com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into dbtester(name,age,email) values ('Aram',18,'[email protected]')' at line 1
Same SQL Query work in MySQL workbench. How I can solve this problem?
String query1 = "insert into dbtester(name,age,email) values ('Aram',18,'[email protected]');";