Initzialer Commit mit dem aktuellen Stand

This commit is contained in:
eichehome 2021-05-11 13:59:08 +02:00
parent ba4867d4f5
commit c50b9c4aff
14 changed files with 2291 additions and 0 deletions

View file

@ -0,0 +1,73 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package client;
import java.io.*;
import java.net.*;
/**
* Hauptklasse des Clients
* @version 0.0.1
* @author eichehome
*/
public class MainClient {
static Socket server = null;
static PrintWriter pr = null;
static BufferedReader bf = null;
static InputStreamReader in = null;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
server = new Socket("localhost", 1236);
pr = new PrintWriter(server.getOutputStream());
pr.println("is it working?");
pr.flush();
in = new InputStreamReader(server.getInputStream());
bf = new BufferedReader(in);
String str = bf.readLine();
System.out.println("server: " + str);
try {
System.out.println("Sleepin for 5 seconds");
Thread.sleep(10000);
} catch (InterruptedException e) {
System.out.println("Thread is interrupted");
}
} catch (IOException e) {
System.err.println("Fehler: " + e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
if (bf != null) {
try {
bf.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
if (pr != null) {
pr.close();
}
if (server != null) {
try {
server.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
}
}
}

View file

@ -0,0 +1,67 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package client;
import java.io.*;
import java.net.*;
/**
* Hauptklasse des Clients
* @version 0.0.1
* @author eichehome
*/
public class MainClient1 {
static Socket server = null;
static PrintWriter pr = null;
static BufferedReader bf = null;
static InputStreamReader in = null;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
server = new Socket("localhost", 1236);
pr = new PrintWriter(server.getOutputStream());
pr.println("is it working?");
pr.flush();
in = new InputStreamReader(server.getInputStream());
bf = new BufferedReader(in);
String str = bf.readLine();
System.out.println("server: " + str);
} catch (IOException e) {
System.err.println("Fehler: " + e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
if (bf != null) {
try {
bf.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
if (pr != null) {
pr.close();
}
if (server != null) {
try {
server.close();
} catch (IOException e) {
System.err.println("Fehler: " + e);
}
}
}
}
}

View file

@ -0,0 +1,47 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;
import java.net.Socket;
/**
*
* @author eichehome
*/
public class ClientMessageDistributorThread implements Runnable {
/**
* Verzeichniss der Threads, die die Clients überwachen
*/
private Socket[] clientThreads = null;
/**
* Puffer der Nachrichten
*/
private Object[] messages = null;
public void run() {
}
public void ClientMessageDistributorThread(Socket s) {
}
public void pushMessage(Object message) {
Object[] temp = new Object[messages.length + 1];
temp[temp.length -1] = message;
messages = temp;
}
public Object popMessage() {
Object[] temp = new Object[messages.length - 1];
Object message = messages[0];
for (int i = 1; i < messages.length; i++) {
temp[i - 1] = messages[i];
}
messages = temp;
}
}

25
src/server/FifoPipe.java Normal file
View file

@ -0,0 +1,25 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;
/**
*
* @author eichehome
*/
public class FifoPipe {
private PipeElement firstElement;
private PipeElement lastElement;
public FifoPipe() {
}
public queuElement(Object element) {
}
}

View file

@ -0,0 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;
import java.io.*;
import java.net.*;
import java.util.concurrent.ExecutionException;
/**
* Hauptklasse des Servers
*
* @version 0.0.1
* @author eichehome
*/
public class MainServer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(1236);
ClientMessageDistributorThread messageDistributor = new ClientMessageDistributorThread();
for (int i = 0; i < 3; i++) {
Socket client = serverSocket.accept();
System.out.println("client connected");
new ServerHandelClientsThread(client, messageDistributor).start();
}
} catch (Exception e) {
System.err.println("Fehler: " + e);
}
}
}

View file

@ -0,0 +1,19 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;
/**
*
* @author eichehome
*/
public class PipeElement {
private PipeElement naechster;
private Object data;
public void setNextElement(Obj)
}

View file

@ -0,0 +1,30 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package server;
import java.io.*;
import java.net.*;
/**
*
* @author eichehome
*/
public class ServerHandelClientsThread extends Thread {
private Socket clientSocket = null;
private ClientMessageDistributorThread messageDistributor = null;
public void run() {
PrintWriter pr = new PrintWriter(clientSocket.getOutputStream(), true);
InputStreamReader in = new InputStreamReader(clientSocket.getInputStream());
BufferedReader bf = new BufferedReader(in);
}
public ServerHandelClientsThread(Socket socket, ClientMessageDistributorThread distributor) {
clientSocket = socket;
messageDistributor = distributor;
}
}

27
src/server/temp Normal file
View file

@ -0,0 +1,27 @@
https://sql-island.informatik.uni-kl.de
SELECT * FROM BEWOHNER
SELECT * FROM bewohner WHERE beruf = 'Metzger'
SELECT * FROM BEWOHNER WHERE status='friedlich'
SELECT * FROM BEWOHNER WHERE status='friedlich' AND beruf='Waffenschmied'
SELECT * FROM BEWOHNER WHERE status='friedlich' AND beruf LIKE '%schmied'
SELECT bewohnernr FROM BEWOHNER WHERE name='Fremder'
SELECT gold FROM BEWOHNER WHERE name='Fremder'
SELECT * FROM GEGENSTAND WHERE besitzer IS NULL
#UPDATE gegenstand SET besitzer = 20 WHERE gegenstand = 'Kaffeetasse'
UPDATE gegenstand SET besitzer = 20 WHERE besitzer IS NULL
SELECT * FROM GEGENSTAND WHERE besitzer = 20
SELECT * FROM BEWOHNER WHERE (beruf = 'Haendler' OR beruf = 'Kaufmann' ) AND status = 'friedlich'
UPDATE gegenstand SET besitzer = 15 WHERE besitzer = 20 AND (gegenstand = 'Ring' OR gegenstand = 'Teekanne')
UPDATE BEWOHNER SET name = 'Eiche Home' WHERE bewohnernr = 20
SELECT * FROM bewohner WHERE beruf = 'Baecker' ORDER BY gold desc
SELECT * FROM bewohner WHERE beruf = 'Pilot'
SELECT dorf.name FROM dorf, bewohner WHERE dorf.dorfnr = bewohner.dorfnr AND bewohner.name = 'Dirty Dieter'
SELECT bewohner.name FROM dorf,bewohner WHERE dorf.name = 'Zwiebelhausen' AND bewohner.bewohnernr = dorf.haeuptling
#SELECT COUNT(*) FROM bewohner, dorf WHERE dorf.dorfnr = bewohner.dorfnr AND dorf.name = 'Zwiebelhausen'
SELECT COUNT(*) FROM dorf,bewohner WHERE dorf.name = 'Zwiebelhausen' AND bewohner.dorfnr = dorf.dorfnr AND geschlecht = 'w'
SELECT bewohner.name FROM dorf,bewohner WHERE dorf.name = 'Zwiebelhausen' AND bewohner.dorfnr = dorf.dorfnr AND geschlecht = 'w'
#SELECT SUM(bewohner.gold) FROM bewohner, dorf WHERE dorf.dorfnr = bewohner.dorfnr AND dorf.name = 'Gurkendorf'
SELECT SUM(gold) FROM bewohner WHERE beruf = 'Baecker' OR beruf = 'Haendler' OR beruf = 'Kaufmann'
#SELECT beruf, SUM(bewohner.gold), AVG(bewohner.gold) FROM bewohner GROUP BY beruf ORDER BY AVG(bewohner.gold)
SELECT status, AVG(gold) FROM bewohner GROUP BY status ORDER BY AVG(gold)