Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void letsGo(){//UPDATE
- con=null;
- try{
- con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/","SA","");
- stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select buchnr, autor from buecher, autoren where buecher.isbn = autoren.isbn");
- while(rs.next()){
- int buchnr = rs.getInt(1);
- String autor = rs.getString(2);
- if(buchnr != altNr){
- altNr = buchnr;
- altAutor = autor;
- }
- else{
- System.out.println("UPDATE zweiautor set autor = '"+autor+", "+altAutor+"' where buchnr = "+altNr+" AND autor = '"+altAutor+"'");
- stmt.executeUpdate("UPDATE zweiautor set autor = '"+autor+", "+altAutor+"' where buchnr = "+altNr+" AND autor = '"+altAutor+"'");
- System.out.println("DELETE FROM zweiautor WHERE buchnr = "+buchnr+" AND autor = '"+autor+"'");
- stmt.executeUpdate("DELETE FROM zweiautor WHERE buchnr = "+buchnr+" AND autor = '"+autor+"'");
- }
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- }
- public static void letsRock(){//INSERT
- con=null;
- try{
- con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/","SA","");
- stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select buchnr, autor from buecher, autoren where buecher.isbn = autoren.isbn");
- while(rs.next()){
- int buchnr = rs.getInt(1);
- String autor = rs.getString(2);
- stmt.executeUpdate("insert into zweiautor values("+buchnr+",'"+autor+"')");
- System.out.println("insert into zweiautor values("+buchnr+",'"+autor+"')");
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement