Package java.sql

Examples of java.sql.Connection


                userName = pc.getUserName();
                xacon = getXADataSource().
                    getXAConnection(userName,
                                    new String(pc.getPassword()));
            }
            Connection con = xacon.getConnection();
            return new CciManagedConnection
                (this, pc, xacon, con, true, true);
        } catch (SQLException ex) {
            ResourceException re =
                new EISSystemException("SQLException: " + ex.getMessage());
View Full Code Here


      info.setProperty(TeiidURL.CONNECTION.USER_NAME, user);
    }
    if (password != null) {
      info.setProperty(TeiidURL.CONNECTION.PASSWORD, password);
    }
    Connection c = TeiidDriver.getInstance().connect(url, info);
    if (c == null) {
      throw new SQLException("Invalid url " + url);
    }
    return new TeiidSql(c);
  }
View Full Code Here

   }

   protected void initDatabase() throws Exception
   {
      DataSource ds = (DataSource)new InitialContext().lookup(datasource);
      Connection conn = ds.getConnection();
      boolean load = false;

      Statement st = conn.createStatement();
      ResultSet rs = null;
      try
      {
         rs = st.executeQuery(existsSql.trim());
         rs.close();
View Full Code Here

 
  /* (non-Javadoc)
   * @see org.hibernate.connection.ConnectionProvider#getConnection()
   */
  public Connection getConnection() throws SQLException {   
    final Connection conn = dataSource.getConnection();
    if(useProxy && conn!=null){
      return (new _Connection(conn,encoding)).getConnection();
    }
    return conn;
  }
View Full Code Here

    Statement statement;
    String SQLQuery = "SELECT LJLEVEL, LCODE, nvl(LSYSLOGEQUIV,LLEVEL)  LSYSLOGEQUIV " +
                        "FROM TLOGLEVEL " +
                    "ORDER BY LLEVEL";
    ResultSet rs = null;
    Connection jdbc_conn = null;
         
    if (formatOK == false)
    {
      logger.log(Level.FATAL, "Connection parameters are not OK");   
    }
    else
   
      try{
        // connect to database
        Class.forName("oracle.jdbc.driver.OracleDriver");
        jdbc_conn = DriverManager.getConnection(JDBCurl, DbUser, DbPass);
         
        logger.debug( "JDBC Connection OK: " + jdbc_conn.toString());
         
        // get the PL/SQL and corresponding LOG4J log levels
        statement = jdbc_conn.createStatement();
        rs = statement.executeQuery(SQLQuery);
           
        if (rs != null)
        {
          while(rs.next())
          {
            Level l = new DynamicLevel (rs.getInt("LJLEVEL"),rs.getString("LCODE"),rs.getInt("LSYSLOGEQUIV"));
                Integer levelint = new Integer(rs.getInt("LSYSLOGEQUIV"));
             
                htLevels.put(levelint, l);
          }
        }
         
        // close the connection
        jdbc_conn.close();   
      }
      catch (SQLException SQLe) {
        logger.fatal("SQL error : " + SQLe);
      }
      catch (Exception e) {
View Full Code Here

  public Object invoke(Object proxy, Method m, Object args[])  throws Throwable
  {
    if (METHOD_NAME.equals(m.getName())){
      try {
        Connection conn = (Connection) m.invoke(dataSource, args);
        return (conn==null)?null:(new _Connection(conn,encoding)).getConnection();
      } catch (InvocationTargetException e) {
        throw e.getTargetException();
      }
    }
View Full Code Here

    }
  }
 
  public static void testCreateTable() throws Exception{
    Class.forName("org.hsqldb.jdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost","sa","");
    PreparedStatement ps = null;
    ResultSet rs = null;
    try{
      //ps = conn.prepareStatement("create table dlog_bookmark (markid INTEGER,logid INTEGER,siteid INTEGER,userid INTEGER,marktype INTEGER,createTime DATE,markorder INTEGER);");
      //ps.executeUpdate();
     
      ps = conn.prepareStatement("SELECT * FROM dlog_user");
      rs = ps.executeQuery();
      while(rs.next()){
        System.out.println(rs.getString("displayName"));
      }
    }finally{
      if(rs!=null)
        rs.close();
      if(ps!=null)
        ps.close();
      if(conn!=null)
        conn.close();
    }
  }
View Full Code Here

    /**
     * Connection to db and return the connection.
     */
    private static Connection createConnection() {
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
        } catch (SQLException e) {
            LOG.fatal(e);
        }
View Full Code Here

     */
    public Connection getConnection(boolean share) {
        if(share && sharedConnection != null) {
            return sharedConnection;
        } else {
            Connection conn = createConnection();
            if(share && sharedConnection == null) {
                sharedConnection = conn;
            }
            return conn;
        }
View Full Code Here

     * @throws QueryTestFailedException
     */
    public Connection getSource(String identifier)
      throws QueryTestFailedException {
 
  Connection conn = this.connStrategy.createDriverConnection(identifier);
  // force autocommit back to true, just in case the last user didnt
  try {
    conn.setAutoCommit(true);
  } catch (Exception sqle) {
    throw new QueryTestFailedException(sqle);
  }
 
  return conn;
View Full Code Here

TOP

Related Classes of java.sql.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.