Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package projket;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9. public class Dejtabejsys {
  10.  
  11.     ResultSet wynikhehe;
  12.     String StringSql = "Select * from InsaneWojtyla"; //Syf zamieniany potem z innych metod
  13.     Connection kabel;
  14.  
  15.     Dejtabejsys() {
  16.         try {
  17.             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  18.         } catch (ClassNotFoundException niewydolność) {
  19.         }
  20.         try {
  21.             kabel = DriverManager.getConnection("jdbc:sqlserver://GARETT\\SQLEXPRESS;user=Czarls;password=123;database=ProfesjonalniePociag");
  22.         } catch (SQLException wylew) {
  23.             System.out.println("Syf w conection");
  24.         }
  25.  
  26.     }
  27.  
  28.     public void setSql(String Sql) {
  29.         this.StringSql = Sql;
  30.     }
  31.  
  32.     public ResultSet ResultzDB() throws SQLException {
  33.         try {
  34.             Statement sta = kabel.createStatement();
  35.             wynikhehe = sta.executeQuery(StringSql);
  36.         } catch (SQLException rak) {
  37.             System.out.println("Zadziała się Wola Boska");
  38.         }
  39.         return wynikhehe;
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement