Esempio n. 1
0
 /** INTERNAL */
 public JdbcConnection(ConnectionInfo ci, boolean useBaseDir) throws SQLException {
   try {
     if (useBaseDir) {
       String baseDir = SysProperties.getBaseDir();
       if (baseDir != null) {
         ci.setBaseDir(baseDir);
       }
     }
     checkJavaVersion();
     // this will return an embedded or server connection
     session = new SessionRemote().createSession(ci);
     trace = session.getTrace();
     int id = getNextId(TraceObject.CONNECTION);
     setTrace(trace, TraceObject.CONNECTION, id);
     this.user = ci.getUserName();
     if (isInfoEnabled()) {
       trace.infoCode(
           "Connection "
               + getTraceObjectName()
               + " = DriverManager.getConnection("
               + quote(ci.getOriginalURL())
               + ", "
               + quote(user)
               + ", \"\");");
     }
     this.url = ci.getURL();
     openStackTrace = new Exception("Stack Trace");
   } catch (Exception e) {
     throw logAndConvert(e);
   }
 }
Esempio n. 2
0
 /** INTERNAL */
 public JdbcConnection(JdbcConnection clone) {
   this.session = clone.session;
   trace = session.getTrace();
   int id = getNextId(TraceObject.CONNECTION);
   setTrace(trace, TraceObject.CONNECTION, id);
   this.user = clone.user;
   this.url = clone.url;
 }
Esempio n. 3
0
 /** INTERNAL */
 public JdbcConnection(SessionInterface session, String user, String url) {
   isInternal = true;
   this.session = session;
   trace = session.getTrace();
   int id = getNextId(TraceObject.CONNECTION);
   setTrace(trace, TraceObject.CONNECTION, id);
   this.user = user;
   this.url = url;
 }
Esempio n. 4
0
 /**
  * INTERNAL. Check if the statement is closed.
  *
  * @param write if the next operation is possibly writing
  * @return true if a reconnect was required
  * @throws SQLException if it is closed
  */
 protected boolean checkClosed(boolean write) throws SQLException {
   if (conn == null) {
     throw Message.getSQLException(ErrorCode.OBJECT_CLOSED);
   }
   conn.checkClosed(write);
   SessionInterface s = conn.getSession();
   if (s != session) {
     session = s;
     setTrace(session.getTrace());
     return true;
   }
   return false;
 }
Esempio n. 5
0
 JdbcStatement(
     JdbcConnection conn,
     int id,
     int resultSetType,
     int resultSetConcurrency,
     boolean closeWithResultSet) {
   this.conn = conn;
   this.session = conn.getSession();
   setTrace(session.getTrace(), TraceObject.STATEMENT, id);
   this.resultSetType = resultSetType;
   this.resultSetConcurrency = resultSetConcurrency;
   this.closedByResultSet = closeWithResultSet;
 }
Esempio n. 6
0
 /**
  * INTERNAL. Check if this connection is closed.
  *
  * @param write if the next operation is possibly writing
  * @throws SQLException if the connection or session is closed
  */
 protected void checkClosed(boolean write) throws SQLException {
   if (session == null) {
     throw DbException.get(ErrorCode.OBJECT_CLOSED);
   }
   if (session.isClosed()) {
     throw DbException.get(ErrorCode.DATABASE_CALLED_AT_SHUTDOWN);
   }
   if (session.isReconnectNeeded(write)) {
     trace.debug("reconnect");
     closePreparedCommands();
     session = session.reconnect(write);
     setTrace(session.getTrace());
   }
 }