Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class JEELab1 {
- public static final String JDBC_URL="jdbc:derby:D://localhost:1527/jee34;user=student;password=wcy";
- public static final String QUERY = "SELECT * FROM student.uzytkownicy";
- public static void main(String[] args) throws SQLException
- {
- Connection conn = DriverManager.getConnection(JDBC_URL);
- System.out.println("Polaczono");
- Statement stat = conn.createStatement();
- ResultSet rs = stat.executeQuery(QUERY);
- System.out.println("\nNazwisko\tImie\t(ID)");
- while(rs.next())
- {
- System.out.println(rs.getString("NAZWISKO")+ "\t\t"
- + rs.getString("IMIE") + "\t\t("
- + rs.getString("ID") + ")");
- }
- if(stat != null)
- {
- stat.close();
- }
- if(conn != null)
- {
- conn.close();
- }
- System.out.println("\nRozlaczono");
- }
- }
- public static Connection getConn() {
- return conn;
- }
- private MyConn(){};
- public static boolean Polacz() throws SQLException
- {
- conn=DriverManager.getConnection(JDBC_URL);
- if (conn==null)
- {
- return false;
- }
- else
- {
- return true;
- }
- };
- public static boolean Rozlacz() throws SQLException
- {
- if (conn==null)
- {
- return false;
- }
- else
- {
- conn.close()
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement