private Connection getConnection() throws SQLException {
   try {
     DriverManager.setLogWriter(new PrintWriter(System.out));
     DriverManager.registerDriver(
         (java.sql.Driver)
             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance());
   } catch (InstantiationException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
   return DriverManager.getConnection(
       txfDatabaseURL.getText(), txfUserName.getText(), txfPassword.getText());
 }
Exemplo n.º 2
0
  public static Connection loadDrivers(String drivername)
      throws SQLException, IOException, ClassNotFoundException, IllegalAccessException,
          InstantiationException {
    String user = P6TestOptions.getActiveInstance().getUser();
    String password = P6TestOptions.getActiveInstance().getPassword();
    String url = P6TestOptions.getActiveInstance().getUrl();

    if (drivername != null) {
      LOG.info("UTIL REGISTERING DRIVER == " + drivername);
      Class<Driver> driverClass = P6Util.forName(drivername);
      DriverManager.setLogWriter(new PrintWriter(System.out, true));
      DriverManager.registerDriver(driverClass.newInstance());
    }
    Driver driver = DriverManager.getDriver(url);
    LOG.info("UTIL USING DRIVER == " + driver.getClass().getName() + " FOR URL " + url);
    Connection connection = DriverManager.getConnection(url, user, password);
    printAllDrivers();
    return connection;
  }
  public static void setLogToSystem(boolean value) {

    // #ifdef JAVA1TARGET
    /*
            try {
                PrintStream newOutStream = (value) ? System.out
                                                   : null;
                DriverManager.setLogStream(newOutStream);
            } catch (Exception e){}
    */

    // #else
    try {
      PrintWriter newPrintWriter = (value) ? new PrintWriter(System.out) : null;

      DriverManager.setLogWriter(newPrintWriter);
    } catch (Exception e) {
    }

    // #endif
  }
Exemplo n.º 4
0
  public void setLogWriter() {
    LogWriter lw = new LogWriter("iudex.da.driver");
    lw.setRemovePattern(LOG_REMOVE_PATTERN);

    DriverManager.setLogWriter(new PrintWriter(lw, true));
  }
Exemplo n.º 5
0
 public void setLogWriter(final PrintWriter writer) {
   DriverManager.setLogWriter(writer);
 }
 @Override
 public void setLogWriter(PrintWriter logWriter) throws SQLException {
   DriverManager.setLogWriter(logWriter);
 }