2 Replies Latest reply on Feb 28, 2007 3:11 PM by g king

    DatabaseMetaData and HTTP connections

    g king Newbie

      Hi,

      I began working with the con.getMetaData() object today and soon after began getting the following:

      org.jboss.deployment.DeploymentException: Too many open files; - nested throwable: (java.io.IOException: Too many open files)
       at org.jboss.web.AbstractWebContainer.init(AbstractWebContainer.java:352)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy31.init(Unknown Source)
       at org.jboss.deployment.MainDeployer.init(MainDeployer.java:843)
       at org.jboss.deployment.MainDeployer.init(MainDeployer.java:863)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:780)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
       at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:489)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:203)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:182)
      Caused by: java.io.IOException: Too many open files
       at java.io.FileInputStream.open(Native Method)
       at java.io.FileInputStream.<init>(FileInputStream.java:106)
       at org.jboss.web.AbstractWebContainer.init(AbstractWebContainer.java:301)
       ... 37 more


      Anyone know the cause?

      Here's the code which causes the problem:

      public DbTable getTable(String ds, String tbl) throws SQLException, NamingException, LookupException{
       DbTable table = null;
       Connection con = null;
       ResultSet rs = null;
       DatabaseMetaData meta = null;
       String[] types = {"TABLE"};
       try {
       con = AppHelper.getConnection(ds);
       meta = con.getMetaData();
       rs = meta.getTables(con.getCatalog(), null, "%"+tbl+"%", types);
       if(!rs.next()) {
       throw new LookupException("Unable to find specified table:"+tbl);
       }
       String name;
       int count = 3;
       do {
       name = rs.getString(count);
       if(name.equals(tbl)) {
       table = new DbTable(name);
       readTableColumns(meta, table);
       break;
       }
       }while(rs.next());
       }finally {
       AppHelper.closeResultSet(rs);
       AppHelper.releaseConnection(con);
       }
       return table;
       }
      
       private void readTableColumns(DatabaseMetaData meta, DbTable table) throws SQLException {
       logger.info("entering readTableColumns");
       ResultSet columns = meta.getColumns(null, "%", table.getTableName(), "%");
       while (columns.next()) {
       String columnName = columns.getString("COLUMN_NAME");
       String datatype = columns.getString("TYPE_NAME");
       int datasize = columns.getInt("COLUMN_SIZE");
       int digits = columns.getInt("DECIMAL_DIGITS");
       int nullable = columns.getInt("NULLABLE");
      
       boolean isNull = (nullable == 1);
      
       DbColumn newColumn = new DbColumn(columnName, datatype, datasize, digits, isNull);
       table.addColumn(newColumn);
       }
       logger.info("leaving readTableColumns");
       }