Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class BazaDanych{
- public static void main(String[] args) throws SQLException {
- Statement statement = null;
- Connection connection = null;
- try {
- Class.forName("org.postgresql.Driver");
- // "jdbc:postgresql://nazwahosta:port/
- // nazwabazy","uzytkownik", "haslo"
- connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/patryk","patryk", "zadanieap");
- // String selectTableSQL = "SELECT * FROM spis;";
- // statement = connection.createStatement();
- //
- // System.out.println(selectTableSQL);
- //
- // // wykonywanie SQL
- // ResultSet rs = statement.executeQuery(selectTableSQL);
- //
- // while (rs.next()) {
- //
- // String id = rs.getString("Id");
- // String imie = rs.getString("Imie");
- // String nazwisko = rs.getString("Nazwisko");
- // String pesel = rs.getString("PESEL");
- // String data_ur = rs.getString("Data_urodzenia");
- // String plec = rs.getString("Plec");
- // String obyw = rs.getString("Obywatelstwo");
- // String zarobki = rs.getString("zarobki");
- //
- // System.out.println("Id: " + id);
- // System.out.println("Imie: " + imie);
- // System.out.println("Nazwisko: " + nazwisko);
- // System.out.println("PESEL: " + pesel);
- // System.out.println("Data urodzenia: " + data_ur);
- // System.out.println("PÅeÄ: : " + plec);
- // System.out.println("Obywatelstwo: : " + obyw);
- // System.out.println("Zarobki: : " + zarobki);
- //
- //
- // }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- System.out.append("Nie masz sterownika");
- }
- catch (SQLException e )
- {
- e.printStackTrace();
- System.out.append("Zle dane");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement