Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- // create a mysql database connection
- String myDriver = "org.gjt.mm.mysql.Driver";
- String myUrl = "jdbc:mysql://localhost/test";
- Class.forName(myDriver);
- Connection conn = DriverManager.getConnection(myUrl, "root", "");
- // the mysql insert statement
- String query = " insert into usuario (nombre, apellido, es_coordinador, remuneracion)"
- + " values (?, ?, ?, ?, ?)";
- // create the mysql insert preparedstatement
- PreparedStatement preparedStmt = conn.prepareStatement(query);
- preparedStmt.setString (1, emp.getNombre());
- preparedStmt.setString (2, emp.getApellido());
- preparedStmt.setBoolean(4, emp.esAdmin());
- preparedStmt.setInt (5, emp.getRemuneracion());
- // execute the preparedstatement
- preparedStmt.execute();
- conn.close();
- }
- catch (Exception e)
- {
- System.err.println("Excepcion!");
- System.err.println(e.getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement