public static boolean loadDB() {
   try {
     Class.forName(DRIVER); // load derby driver
   } catch (java.lang.ClassNotFoundException e) {
     System.out.println("failed to load Derby embedded driver " + e.toString());
     return false;
   }
   return true;
 }
Exemple #2
0
  public static void main(String args[]) {
    // String url = "jdbc:mySubprotocol:myDataSource";
    String url = "jdbc:oracle:thin:@211.154.39.114:11101:DEV";
    Connection con;
    String createString;
    /*createString = "create table COFFEES " +
    "(COF_NAME VARCHAR(32), " +
    "SUP_ID INTEGER, " +
    "PRICE FLOAT, " +
    "SALES INTEGER, " +
    "TOTAL INTEGER)";*/
    createString =
        "create table COFFEES "
            + "(COF_NAME VARCHAR2(32), "
            + "SUP_ID NUMBER, "
            + "PRICE NUMBER, "
            + "SALES NUMBER, "
            + "TOTAL NUMBER)";
    Statement stmt;

    try {
      // Class.forName("myDriver.ClassName");
      Class.forName("oracle.jdbc.driver.OracleDriver");
    } catch (java.lang.ClassNotFoundException e) {
      System.err.print("ClassNotFoundException: ");
      System.err.println(e.getMessage());
    }

    try {
      // con = DriverManager.getConnection(url, "myLogin", "myPassword");
      con = DriverManager.getConnection(url, "apps", "apps");
      stmt = con.createStatement();
      stmt.executeUpdate(createString);
      stmt.close();
      con.close();

    } catch (SQLException ex) {
      System.err.println("SQLException: " + ex.getMessage());
    }
  }
Exemple #3
0
  public void Connect() {

    String url = "jdbc:mysql://184.172.173.42:3306/chichiu_Itp2";

    try {
      Class.forName("com.mysql.jdbc.Driver");

    } catch (java.lang.ClassNotFoundException e) {
      System.err.print("ClassNotFoundException: ");
      System.err.println(e.getMessage());
    }

    try {

      MainMenu.con = DriverManager.getConnection(url, "chichiu_anroth", "it12345");

    } catch (SQLException ex) {
      System.err.print("SQLException: ");
      System.err.println(ex.getMessage());
    }
    ;
  }