Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class JavaBD {
  4.  
  5. public static void main(String[] args) {
  6. Connection con;
  7. try {
  8. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  9. con = DriverManager.getConnection("jdbc:sqlserver://" + "153.19.7.13:1401; databaseName=drodzevic;user=drodzevic;password=253957");
  10. String query = "SELECT * FROM adres";
  11. ResultSet result = con.createStatement().executeQuery(query);
  12. ResultSetMetaData countCol = result.getMetaData();
  13.  
  14. while(result.next()) {
  15. for(int i = 1; i<countCol.getColumnCount(); i++) {
  16. System.out.println(result.getString(i) + " | ");
  17. }
  18. }
  19.  
  20. while(wynik_zapytania.next())
  21. {
  22. for (int i=1;i<=ile_kolumn;i++)
  23. {
  24. 11. System.out.print(wynik_zapytania.getString(i)+" - ");
  25. 12. }
  26. 13. System.out.println(" <koniec>");
  27. 14. }
  28.  
  29.  
  30. }catch (SQLException e) {
  31. System.out.println("zle");
  32. e.printStackTrace();
  33. }
  34. catch (ClassNotFoundException e) {
  35. System.out.println("zle2");
  36. e.printStackTrace();
  37. }
  38.  
  39.  
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement