Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- // Extends java.sql :~ describes connections to Oracle db
- class dbConn {
- Connection conn;
- Statement stmt;
- ResultSet rs;
- String conString;
- String sqlString;
- void dbConn() {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- conn = DriverManager.getConnection(conString);
- } catch (ClassNotFoundException | SQLException e) {
- e.printStackTrace();
- }
- if (conn != null) {
- System.out.println("Connection established, database uplink is online.");
- } else {
- System.out.println("Connection failed, please check database status.");
- }
- }
- }
- import javax.swing.*;
- public class CaseMoverUI {
- void testUI(){
- // Create a new JFrame container
- JFrame jfrm = new JFrame("CaseMover");
- jfrm.setSize(550, 450);
- jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JComboBox jbox = new JComboBox();
- jfrm.add(jbox);
- jfrm.setVisible(true);
- SwingUtilities.invokeLater(new Runnable(){
- public void run(){
- new CaseMoverUI();
- }
- });
- }
- }
- public class sqlCaller {
- public static void main(String args[]){
- //instantiate db object and pass values to the constructor
- dbConn db = new dbConn();
- db.conString = "jdbc:oracle:thin:system/jamie123@127.0.0.1:1521:xe";
- db.sqlString = "SELECT true FROM dual";
- db.dbConn();
- CaseMoverUI ui = new CaseMoverUI();
- ui.testUI();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement