Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void añadirDatosSQL() {
- for(Empleado e : empleados)
- {
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost/empleados", "usuario","123456");
- Statement sentencia = conexion.createStatement();
- boolean resul = sentencia.execute("INSERT INTO empleado VALUES("+ e.getId() + e.getNombre() + e.getApell1() + e.getApell2() + e.getSalario() + ")");
- }
- catch(ClassNotFoundException | SQLException err)
- {
- System.out.println("Error al conectar a la base de datos");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement