Heja.
Mam powazny problem ;) wyciskam poty na zadanko do szkoły i napotkałem się na ogromną przeszkodę.
Otóż mam programik serwerowy który ma łączyć się z bazą danych (systemowe ODBC) i za pomoca watkow obslugiwac klientow w sposob wspolbiezny. Mam problem przy metodzie run()
@Override public void run() throws IOException , ClassNotFoundException , SQLException
{
String mojeDSN = "Loty";
String dbURL = "jdbc:odbc:" + mojeDSN;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbURL, "","");
Statement s = con.createStatement();
PrintWriter out = new PrintWriter(commsock.getOutputStream(), true);
BufferedReader in = new BufferedReader( new InputStreamReader(commsock.getInputStream()));
String inputLine, outputLine;
System.out.println("Watek oblsugi klienta uruchomiony");
boolean x = true;
do
{
String selectString = null;
String[] tabKolumn = null;
String[] tabRekordKolumn = new String[1];
outputLine = "Tabela \"Przyloty\" zawiera kolejno kolumny: ID, Carrier, Flight Number, Time, Gate, City, Remarks";
out.println(outputLine);
outputLine = "Podaj kolumny bazy oddzielone tylko przecinkami: ";
out.println(outputLine);
String kolumny = in.readLine();
tabKolumn = kolumny.split(",");
outputLine = "Podaj kolumne szukanego rekordu: ";
out.println(outputLine);
String rekordKolumn = in.readLine();
tabRekordKolumn[0] = rekordKolumn;
outputLine = "Podaj wyszukiwany rekord: ";
out.println(outputLine);
String rekord = in.readLine();
}while(x);
in.close();
out.close();
s.close();
con.close();
commsock.close();
}
pierwsza linia w NetBeans podkresla mi sie na czerwono blędem i nie kompiluje. Oto tresc errora:
run() in program.Watek cannot implement run() in java.lang.Runnable; overriden method does not throw java.sql.SQLException
probowalem z try i catch ale zas wtedy podkresla mi że
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbURL, "","");
unreported exception java.sql.SQLException; must be declared to be thrown
proszę pomocy :D
z góry dziękuję
sheezol