Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void insertarLibro()
- {
- String url = "jdbc:sqlserver://localhost:1433;databaseName=Biblioteca";
- String user = "mi_usuario";
- String password = "mi_contraseña";
- String fk_dni = "SELECT dni FROM Autores WHERE nombre = '?'";
- try
- {
- Connection cn = DriverManager.getConnection(url, user, password);
- PreparedStatement ps = cn.prepareStatement(fk_dni);
- ResultSet rs = ps.executeQuery();
- String nombre = (String)cboAutor.getSelectedItem();
- while(rs.next())
- {
- ps.setString(1, nombre);
- }
- System.out.println("DNI : " + rs.getString(1));
- }
- catch(SQLException e)
- {
- System.out.println("ERROR : ");
- e.printStackTrace(System.out);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement