Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zad1;
- import java.sql.*;
- public class Database {
- String url;
- String username = "s14245";
- String password = "oracle12";
- Connection con = null;
- public Database(String url, TravelData travelData) {
- this.url=url;
- }
- public void create() {
- System.out.println("ŁĄCZENIE Z BAZĄ DANYCH...");
- //polaczenie z baza danych Oracle
- try{
- //sterownik
- Class.forName("oracle.jdbc.driver.OracleDriver");
- System.out.println("Sterowniki załadowane");
- //polaczenie z baza
- con = DriverManager.getConnection(url, username, password);
- System.out.println("Połączenie nawiązane");
- }catch (ClassNotFoundException exc) { // brak klasy sterownika
- System.out.println("Brak klasy sterownika");
- System.out.println(exc);
- System.exit(1);
- }catch(SQLException exc) { // nieudane połączenie
- System.out.println("Nieudane połączenie z " + url);
- System.out.println(exc);
- System.exit(1);
- }
- /*
- //zapytanie do bazy
- String query = "SELECT * FROM EMP";
- Statement statement;
- try {
- statement = con.createStatement();
- ResultSet rs = statement.executeQuery(query);
- //wypisywanie z tabeli
- while(rs.next()){
- try{
- String daneZBazy = rs.getString(1);
- System.out.println("\n" + daneZBazy + " ");
- daneZBazy = rs.getString(2);
- System.out.println(daneZBazy + " ");
- daneZBazy = rs.getString(3);
- System.out.println(daneZBazy);
- daneZBazy = rs.getString(4);
- System.out.println(daneZBazy);
- }catch(SQLException e) {
- e.printStackTrace();
- }
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- */
- }
- public void showGui() {
- }
- }
- package zad1;
- import java.io.*;
- import java.util.*;
- public class TravelData {
- String adres_pliku = "data/oferty.txt";
- String loc, kraj, miejsce, symbol_waluty;
- double cena;
- String data_wyjazdu, data_powrotu;
- public TravelData(File dataDir) {
- dataDir = new File(adres_pliku);
- // ODCZYT PLIKU .TXT
- String linia;
- BufferedReader bfr = null;
- try {
- bfr = new BufferedReader(new FileReader(dataDir));
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
- // ODCZYT KOLEJNYCH LINII Z PLIKU:
- try {
- while((linia = bfr.readLine()) != null){
- System.out.println(linia);
- }
- } catch (IOException e) {
- System.out.println("BŁĄD ODCZYTU Z PLIKU!");
- System.exit(2);
- }
- }
- public List<String> getOffersDescriptionsList(String locale, String dateFormat) {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement