Parallele und gestaffelte Datenbankserver 7 Parallele und gestaffelte Datenbankserver Grössere Datenverwaltungen folgen der Client-/Server-Architektur. Es gibt verschiedene Möglichkeiten, das Client-/Server-Prinzip zu realisieren: Parallele Server: import java.sql.*; public class FuenfSchrittealle { public static void main(String[] args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c1 = DriverManager.getConnection("jdbc:odbc:accessdb","",""); Statement s1 = c1.createStatement(); ResultSet r1 = s1.executeQuery("SELECT * FROM person"); while (r1.next()) { System.out.println(r1.getString("vorname") + " " + r1.getString("nachname")); } System.out.println(); Connection c2 = DriverManager.getConnection("jdbc:odbc:sqlserverdb","student","student"); Statement s2 = c2.createStatement(); ResultSet r2 = s2.executeQuery("SELECT * FROM person"); while (r2.next()) { System.out.println(r2.getString("vorname") + " " + r2.getString("nachname")); } System.out.println(); Connection c3 = DriverManager.getConnection("jdbc:odbc:mysqldb","",""); Statement s3 = c3.createStatement(); ResultSet r3 = s3.executeQuery("SELECT * FROM person"); while (r3.next()) { System.out.println(r3.getString("vorname") + " " + r3.getString("nachname")); } TFH Berlin/Steyer Parallele und gestaffelte Datenbankserver c1.close(); c2.close(); c3.close(); } } Gestaffelte Server: import java.sql.*; public class FuenfSchrittesub { public static void main(String[] args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c = DriverManager.getConnection("jdbc:odbc:accessdb","",""); Statement s1 = c.createStatement(); ResultSet r1 = s1.executeQuery("SELECT * FROM person"); while (r1.next()) { System.out.println(r1.getString("vorname") + " " + r1.getString("nachname")); } System.out.println(); Statement s2 = c.createStatement(); ResultSet r2 = s2.executeQuery("SELECT * FROM dbo_person"); while (r2.next()) { System.out.println(r2.getString("vorname") + " " + r2.getString("nachname")); } System.out.println(); Statement s3 = c.createStatement(); ResultSet r3 = s3.executeQuery("SELECT * FROM person1"); while (r3.next()) { System.out.println(r3.getString("vorname") + " " + r3.getString("nachname")); } c.close(); } } TFH Berlin/Steyer