1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| import java.sql.*;
public class test2 {
public static void main(String[]arg){
Connection connection = null;
try{ Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/mourad";
String user = "root";
String password = "";
connection = DriverManager.getConnection(url, user, password);
Statement stmt = connection.createStatement();
String sql = "INSERT INTO users (id,name, address) VALUES (1,'Foo', 'Street')";
stmt.execute(sql);
connection.close();}catch(Exception e ){
}
}
} |
Partager