Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MBiblioteca {
- private String autor;
- public MBiblioteca(String autor){
- this.autor = autor ;
- }
- public MAutor getAutor(){
- Connection conexion= DriverManager.getConnection(
- "jdbc:derby://localhost:1527/biblioteca",
- "app",
- "app");
- ResultSet resultado = conexion.createStatement.executeQuerry(
- "SELECT idAutor FROM Autores WHERE nombre="+autor );
- if (resultado.hasNext() ){
- int idAutor = resultado.getInt( "idAutor");
- return new MAutor(idAutor);
- } else return null;
- }
- }
- public class MAutor {
- private int idAutor;
- public MAutor ( int idAutor ){
- this.idAutor= idAutor;
- }
- public String getNombre(){
- Connection conexion= DriverManager.getConnection(
- "jdbc:derby://localhost:1527/biblioteca",
- "app",
- "app");
- ResultSet resultado = conexion.createStatement.executeQuerry(
- "SELECT nombre FROM Autores WHERE idAutor="+autor );
- if (resultado.hasNext() ){
- String nombre = resultado.getString( "nombre");
- return new MAutor( "nombre" );
- } else return null;
- }
- public ArrayList<MLibros> getMLibros (){
- Connection conexion= DriverManager.getConnection(
- "jdbc:derby://localhost:1527/biblioteca",
- "app",
- "app");
- ResultSet resultado = conexion.createStatement.executeQuerry(
- "SELECT idLibro FROM LibrosAutores WHERE idAutor="+autor );
- Arraylist<MLibros> lista = new ArrayList<MLibros>();
- while (resultado.hasNext() ){
- lista.add(new Mlibro(resultado.getInt("idLibro")));
- }
- return lista;
- }
- }
- public class MLibro {
- private int idLibro;
- public MLibro ( int idLibro ){
- this.idLibro= idLibro;
- }
- public String getNombre(){
- Connection conexion= DriverManager.getConnection(
- "jdbc:derby://localhost:1527/biblioteca",
- "app",
- "app");
- ResultSet resultado = conexion.createStatement.executeQuerry(
- "SELECT nombre FROM Libros WHERE idLibro="+idLibro );
- if (resultado.hasNext() ){
- String nombre = resultado.getString( "nombre");
- return new MAutor( "nombre" );
- } else return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement