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 lab_jdbc;
- /**
- *
- * @author student
- */
- import java.sql.*;
- import java.util.Properties;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class Lab_JDBC {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Connection conn = null;
- Properties connectionProps = new Properties();
- connectionProps.put("user", "login");
- connectionProps.put("password", "haslo");
- try{
- conn = DriverManager.getConnection(
- "jdbc:oracle:thin:@//admlab2.cs.put.poznan.pl:1521/"
- + "dblab02_students.cs.put.poznan.pl",
- connectionProps);
- System.out.println("Połączono z bazą danych");
- }
- catch
- (SQLException ex) {
- Logger.getLogger(Lab_JDBC.class.getName()).log(Level.SEVERE,"nie udało się połączyć z bazą danych", ex);
- System.exit(-1);
- }
- System.out.println("Połączono z DB");
- Statement stmt;
- stmt = conn.createStatement();
- try {
- conn.close();
- System.out.println("Rozłączona z DB");
- } catch (SQLException ex) {
- Logger.getLogger(Lab_JDBC.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement