Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.sql.Statement;
  6.  
  7. // Extends java.sql :~ describes connections to Oracle db
  8. class dbConn {
  9.  
  10. Connection conn;
  11. Statement stmt;
  12. ResultSet rs;
  13. String conString;
  14. String sqlString;
  15.  
  16. void dbConn() {
  17. try {
  18. Class.forName("oracle.jdbc.driver.OracleDriver");
  19. conn = DriverManager.getConnection(conString);
  20. } catch (ClassNotFoundException | SQLException e) {
  21. e.printStackTrace();
  22. }
  23. if (conn != null) {
  24. System.out.println("Connection established, database uplink is online.");
  25. } else {
  26. System.out.println("Connection failed, please check database status.");
  27. }
  28. }
  29. }
  30.  
  31. import javax.swing.*;
  32.  
  33. public class CaseMoverUI {
  34. void testUI(){
  35.  
  36. // Create a new JFrame container
  37. JFrame jfrm = new JFrame("CaseMover");
  38. jfrm.setSize(550, 450);
  39. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  40. JComboBox jbox = new JComboBox();
  41. jfrm.add(jbox);
  42. jfrm.setVisible(true);
  43. SwingUtilities.invokeLater(new Runnable(){
  44. public void run(){
  45. new CaseMoverUI();
  46. }
  47. });
  48. }
  49. }
  50.  
  51. public class sqlCaller {
  52. public static void main(String args[]){
  53. //instantiate db object and pass values to the constructor
  54. dbConn db = new dbConn();
  55. db.conString = "jdbc:oracle:thin:system/jamie123@127.0.0.1:1521:xe";
  56. db.sqlString = "SELECT true FROM dual";
  57.  
  58. db.dbConn();
  59. CaseMoverUI ui = new CaseMoverUI();
  60. ui.testUI();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement