Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 inf122419;
- /**
- *
- * @author student
- */
- import java.sql.*;
- import java.util.Properties;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class Inf122419 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Connection conn = null;
- Properties connectionProps = new Properties();
- connectionProps.put("user", "inf122419");
- connectionProps.put("password", "inf122419");
- try {
- conn = DriverManager.getConnection("jdbc:oracle:thin:@//admlab2.cs.put.poznan.pl:1521/dblab02_students.cs.put.poznan.pl", connectionProps);
- conn.setAutoCommit(false);
- System.out.println("Połączono z bazą danych");
- } catch (SQLException ex) {
- Logger.getLogger(Inf122419.class.getName()).log(Level.SEVERE,
- "nie udało się połączyć z bazą danych", ex);
- System.exit(-1);
- }
- Statement stmt = null;
- ResultSet rs = null;
- try {
- stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_READ_ONLY);
- rs = stmt.executeQuery("select nazwisko " + "from pracownicy " + "where etat='ASYSTENT' order by placa_pod DESC");
- rs.last();
- System.out.println("Asystent zarabiający najmniej " + rs.getString(1));
- } catch (SQLException ex) {
- System.out.println("Bład wykonania polecenia" + ex.toString());
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- /* kod obsługi */ }
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- /* kod obsługi */ }
- }
- }
- try {
- conn.close();
- } catch (SQLException ex) {
- Logger.getLogger(Inf122419.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.println("Odłączono z bazą danych");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement