Package org.jdbf.engine.mapping

Examples of org.jdbf.engine.mapping.DatabaseMap


     * @exception MappingException if an error occurs
     */
    public void createConnection(List dbs)
        throws MappingException{
   
    DatabaseMap dbMap = null;
        logger.log(Level.INFO,Messages.message("ConnectionManager.createConnection"));
    try{
     
        for(int i = 0; i < dbs.size(); i++){
        dbMap = (DatabaseMap) dbs.get(i);
         
                Class.forName(dbMap.getDbDriver());
        Connection conn = DriverManager.getConnection(dbMap.getDbServer(),
                                    dbMap.getDbLogin(),dbMap.getDbPassword());
                Object params[] = {dbMap.getName(),
                                   dbMap.getDbServer(),
                                   dbMap.getDbLogin(),
                                   dbMap.getDbPassword()
                                  };

        conn.setAutoCommit(false);
               
                logger.log(Level.FINEST,Messages.format(
                                "ConnectionManager.connection",params));
   
                addConnection(dbMap.getName(),new ConnectionSource(conn,
                                  dbMap.getVendor()));
               
                logger.log(Level.FINEST,Messages.format(
                                "Connection.connectionAdded",dbMap.getName()));
        }
    }
    catch(ClassNotFoundException e){
        logger.throwing(CLASS_NAME,"createConnection()",
                            new MappingException("class.noClassDefFound",dbMap.getDbDriver())
                           );
            throw new MappingException("class.noClassDefFound",dbMap.getDbDriver());
    }
    catch(SQLException e){
        logger.throwing(CLASS_NAME,"createConnection()",
                            new MappingException("mapping.connNotFound",dbMap.getDbServer())
                           );
            throw new MappingException("mapping.connNotFound",dbMap.getDbServer());
    }   
    }
View Full Code Here


       
    Iterator iter = conf.getConfigurations("database");
    ArrayList dbs = new ArrayList();
    while(iter.hasNext()){
        conf = (ConfigurationImpl)iter.next();
        DatabaseMap dbMap = new DatabaseMap();
        ConfigurationImpl child = (ConfigurationImpl)conf.getConfiguration("name");
            logger.log(Level.FINEST,"name " + child.getValue());
        dbMap.setName(child.getValue());
        child = (ConfigurationImpl)conf.getConfiguration("vendor");
            logger.log(Level.FINEST,"vendor " + child.getValue());
        dbMap.setVendor(child.getValue());
        child = (ConfigurationImpl)conf.getConfiguration("dbDriver");
            logger.log(Level.FINEST,"dbDriver " + child.getValue());
        String dbDriver = child.getValue();
        if(dbDriver == null){       
              logger.throwing(CLASS_NAME,"createConnection()",
                            new MappingException("mapping.missingDriver")
                           );
            throw new MappingException(Messages.message("mapping.missingDriver"));
        }
        else
        dbMap.setDbDriver(dbDriver);
     
        child = (ConfigurationImpl)conf.getConfiguration("dbServer");
            logger.log(Level.FINEST,"dbServer " + child.getValue());
        dbMap.setDbServer(child.getValue());
        child = (ConfigurationImpl)conf.getConfiguration("dbLogin");
            logger.log(Level.FINEST,"dbLogin " + child.getValue());
        dbMap.setDbLogin(child.getValue());
        child = (ConfigurationImpl)conf.getConfiguration("dbPassword");
            logger.log(Level.FINEST,"dbPassword " + child.getValue());
        dbMap.setDbPassword(child.getValue());
     
        dbs.add(dbMap);
    }
    createConnection(dbs);
    }
View Full Code Here

TOP

Related Classes of org.jdbf.engine.mapping.DatabaseMap

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.