Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class Austoben {
- public static final String Select = "SELECT WKN, Name FROM Wertpapier WHERE TYP = 'AKTIE' ORDER BY NAME ";
- //public static Connection conn = null;
- public static void main(String[] args) throws SQLException {
- new oracle.jdbc.OracleDriver();
- Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@orahost:1521:infdb", "gruberc2", "gruberc2");
- Statement stmt = conn.createStatement();
- int bLines = stmt.executeUpdate("DELETE FROM BRANCHE WHERE BID = 1");
- System.out.println("Gelöschte Zeilen: " + bLines);
- int cLines = stmt.executeUpdate("INSERT INTO Branche(BID, Name) VALUES (1, 'Telekommunikation')");
- System.out.println("Hinzugefügte Zeilen: " + cLines);
- //int nLines = stmt.executeUpdate("DELETE FROM Branche WHERE BID BETWEEN 13 AND 20");
- //System.out.println("GELÖSCHTE ZEILEN: " + nLines);
- int dLines = stmt.executeUpdate("INSERT ALL INTO Branche(BID, Name) VALUES (15, 'Test 1')"
- + "INTO BRANCHE(BID, Name) VALUES(16, 'Test2')"
- + "INTO BRANCHE(BID, Name) VALUES(17, 'Test3')"
- + "SELECT * FROM DUAL");
- System.out.println("Hinzugefügte Zeilen: " + dLines);
- int aLines = stmt.executeUpdate("UPDATE Branche SET Name = 'Chris' WHERE BID = 1");
- System.out.println("Geänderte Zeilen: " + aLines);
- //ResultSet rset1 = stmt.executeQuery("SELECT * FROM BRANCHE ORDER BY BID ASC");
- //System.out.println();
- PreparedStatement pStmt = conn.prepareStatement(Select);
- ResultSet rset = pStmt.executeQuery();
- while(rset.next())
- System.out.println("WKN: " + rset.getInt("WKN") + " Name: " + rset.getString("Name"));
- rset = stmt.executeQuery("SELECT * FROM BRANCHE ORDER BY BID ASC");
- while(rset.next())
- System.out.println("BID: " + rset.getInt("BID") + " BRANCHE: " + rset.getString("NAME") + "\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement