CoboCards App FAQ & Wishes Feedback
Language: English Language
Sign up for free  Login

This flashcard is just one of a free flashcard set. See all flashcards!

All main topics / Informaticsk / DBS1 / Hiesch_Datenbankprogrammierung_Datenbankentwurf
34
JDBC Ablauf Abfrage

C(onnection), S(tatement), R(esultSet)
0. Parameter Definieren:
String ConnectionURL ="jdbc:mysql://localhost:3306/dhbw";
String user = "root";
String pw="";
String query1 ="SELECT * FROM Student";

1. Connection
Connection con = null;
con = DriverManager.getConnection(ConnectionURL,user,pw);

2. Statement erstellen
Statement stmt1 = con.createStatement();

3. Statement ausführen
ResultSet rset1 = stmt1.executeQuery(query1);
bzw.
executeQuery (SELECT)
executeUpdate (DELETE, INSERT, UPDATE)

4. ResultSet auswerten
getXXX("Spalte"); Methoden für alle primitiven Java-Datentypen
->getString() funktioniert immer!

while (rset.next()) {
System.out.println(“MNr.: ”+rset.getInt(‚MNr‘)+“ Land: “+rset.getString(2));
}

5. Ressourcen freigebe
close(); Methode
rset1.close();
stmt1.close();
con.close();
New comment
Flashcard info:
Author: learner94
Main topic: Informaticsk
Topic: DBS1
Published: 26.08.2017

Cancel
Email

Password

Login    

Forgot password?
Deutsch  English