Advertisement
Guest User

java

a guest
Apr 9th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.92 KB | None | 0 0
  1. package model;
  2. import java.sql.Date;
  3. import java.sql.Time;
  4. import java.sql.Timestamp;
  5. import java.time.Clock;
  6.  
  7.  
  8. public class Zamestnanec {
  9.     private Integer id;
  10.     private String meno;
  11.     private Date narodeny;
  12.     private Integer plat;
  13.     private Timestamp zamestnany_od;
  14.     private Boolean muz;
  15.  
  16.     public Integer getId() {return id;}
  17.     public void setId(Integer id) {this.id = id;}
  18.  
  19.     public String getMeno() {return meno;}
  20.     public void setMeno(String meno) {this.meno = meno;}
  21.  
  22.     public Date getNarodeny() {return narodeny;}
  23.     public void setNarodeny(Date narodeny) {this.narodeny = narodeny;}
  24.  
  25.     public Integer getPlat() {return plat;}
  26.     public void setPlat(Integer plat) {this.plat = plat;}
  27.  
  28.     public Timestamp getZamestnany_od() {return zamestnany_od;}
  29.     public void setZamestnany_od(Timestamp zamestnany_od){ this.zamestnany_od = zamestnany_od;}
  30.  
  31.     public Boolean getMuz() { return muz;}
  32.     public void setMuz(Boolean muz) {this.muz = this.muz;}
  33.  
  34.  
  35.     public Zamestnanec() {
  36.     }
  37.  
  38.     public Zamestnanec(Integer id, String meno,Date narodeny, Integer plat,Timestamp zamestnany_od,Boolean muz){
  39.         setId(id);
  40.         setMeno(meno);
  41.         setNarodeny(narodeny);
  42.         setPlat(plat);
  43.         setZamestnany_od(zamestnany_od);
  44.         setMuz(muz);
  45.     }
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. import org.postgresql.ds.PGPoolingDataSource;
  63.  
  64. import java.sql.Connection;
  65. import java.sql.DriverManager;
  66. import java.sql.ResultSet;
  67. import java.sql.SQLException;
  68. import java.sql.Statement;
  69. import java.util.HashMap;
  70. import java.util.Iterator;
  71. import java.util.LinkedList;
  72. import java.util.List;
  73. import java.util.Properties;
  74. import java.util.Random;
  75.  
  76. public class Runner {
  77.     public static void main(String[] args) throws SQLException {
  78.  
  79.         PGPoolingDataSource source = new PGPoolingDataSource();
  80.         source.setDataSourceName("A Data Source");
  81.         source.setServerName("localhost");
  82.         source.setDatabaseName("projekt_DBS");
  83.         source.setUser("bruno");
  84.         source.setPassword("fiit");
  85.         source.setMaxConnections(10);
  86.  
  87.         Connection conn = null;
  88.         Properties connectionProps = new Properties();
  89.         connectionProps.put("user", "bruno");
  90.         connectionProps.put("password", "fiit");
  91.         String connectionString = "jdbc:postgresql://localhost:5432/projekt_DBS";
  92.  
  93.         try {
  94.  
  95.             conn = DriverManager.getConnection(
  96.                     "jdbc:postgresql://localhost:5432/projekt_DBS", "bruno",
  97.                     "fiit");
  98.  
  99.         } catch (SQLException e) {
  100.  
  101.             System.out.println("Connection Failed! Check output console");
  102.             e.printStackTrace();
  103.             return;
  104.  
  105.         }
  106.  
  107.         if (conn != null) {
  108.             System.out.println("You made it, take control your database now!");
  109.         } else {
  110.             System.out.println("Failed to make connection!");
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement