Advertisement
Guest User

Untitled

a guest
May 17th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. package proba;
  2.  
  3. import org.eclipse.swt.widgets.Composite;
  4. import org.eclipse.swt.widgets.Display;
  5. import org.eclipse.swt.widgets.Shell;
  6. import org.eclipse.swt.custom.ScrolledComposite;
  7.  
  8. import java.awt.Component;
  9. import java.sql.Connection;
  10. import java.sql.DriverManager;
  11. import java.sql.ResultSet;
  12. import java.sql.Statement;
  13.  
  14. import javax.swing.*;
  15.  
  16. import org.eclipse.swt.SWT;
  17. import org.eclipse.swt.widgets.Label;
  18. import org.eclipse.wb.swt.SWTResourceManager;
  19. import org.eclipse.swt.widgets.List;
  20. import org.eclipse.swt.layout.GridLayout;
  21. import org.eclipse.swt.layout.GridData;
  22.  
  23. public class pregPod {
  24.  
  25. protected Shell shell;
  26.  
  27. /**
  28. * Launch the application.
  29. * @param args
  30. */
  31. public static void noviProzPP() {
  32. try {
  33. pregPod window = new pregPod();
  34. window.open();
  35. } catch (Exception e) {
  36. e.printStackTrace();
  37. }
  38. }
  39.  
  40. /**
  41. * Open the window.
  42. */
  43. public void open() {
  44. Display display = Display.getDefault();
  45. createContents();
  46. shell.open();
  47. shell.layout();
  48. while (!shell.isDisposed()) {
  49. if (!display.readAndDispatch()) {
  50. display.sleep();
  51. }
  52. }
  53. }
  54.  
  55. /**
  56. * Create contents of the window.
  57. * @wbp.parser.entryPoint
  58. */
  59. protected void createContents() {
  60. shell = new Shell();
  61. shell.setSize(450, 300);
  62. shell.setText("SWT Application");
  63. shell.setLayout(null);
  64.  
  65. ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
  66. scrolledComposite.setBounds(0, 10, 422, 238);
  67. scrolledComposite.setExpandHorizontal(true);
  68. scrolledComposite.setExpandVertical(true);
  69.  
  70. Composite composite = new Composite(scrolledComposite, SWT.NONE);
  71. composite.setLayout(new GridLayout(1, false));
  72.  
  73. Label lblNewLabel = new Label(composite, SWT.NONE);
  74. GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
  75. gd_lblNewLabel.heightHint = 229;
  76. gd_lblNewLabel.widthHint = 418;
  77. lblNewLabel.setLayoutData(gd_lblNewLabel);
  78. scrolledComposite.setContent(composite);
  79. scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  80.  
  81.  
  82.  
  83.  
  84. try {
  85. String sveskupa = "";
  86.  
  87. String url = "jdbc:mysql://localhost:3306/database?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CET";
  88. Connection conn = DriverManager.getConnection(url,"root","");
  89. Statement st = conn.createStatement();
  90. ResultSet brRedaka = st.executeQuery("SELECT * FROM `javni_pod`");
  91.  
  92. while(brRedaka.next()) {
  93. String put = brRedaka.getString("path");
  94. String ajdi = brRedaka.getString("ID");
  95. sveskupa = sveskupa + ajdi + " " + put + "\n";
  96.  
  97. lblNewLabel.setText(sveskupa + "\n");
  98.  
  99.  
  100.  
  101.  
  102.  
  103. System.out.println(ajdi + " " + put);
  104.  
  105. }
  106.  
  107. conn.close();
  108. } catch (Exception e) {
  109. System.err.println("Got an exception! ");
  110. System.err.println(e.getMessage());
  111. }
  112.  
  113.  
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement