示例#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);
   }
 }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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());
   }
 }