Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void agregarcli(Cliente cli)
- {
- Statement st=null;
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- conexion = DriverManager.getConnection("jdbc:mysql://localhost/ivo9", "root", "llbntl");
- st = conexion.createStatement();
- st.executeUpdate("INSERT INTO clientes (nombre, direccion) VALUES ('"+cli.getNom()+"','"+cli.getDomic()+"' )");
- }
- catch(Exception e)
- {
- System.out.println(e.getMessage());
- }
- finally{
- if(st!=null){
- try {
- st.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- if (conexion != null){
- try {
- conexion.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment