0 Replies Latest reply on Nov 23, 2005 10:52 AM by kanna k7

    getting primarykey using datasource

    kanna k7 Newbie

      Hi,
      Thanks in advance.I got struck in the middle of a problem and please help me.

      In my application i am using datasouce and performing all operations without establishing any connections as this:

      JdbcTemplate jt = new JdbcTemplate(datasource);
      List result=jt.queryForList(query);

      Now I want to get the primary keys of a table.Is there any way to get primarykeys directly from datasource.I want to get direectly from the datasource.

      I tried to get primary key using connections also as follows:

      Connection con = DataSourceUtils.doGetConnection(datasource);
      datasource.getConnection();
      DatabaseMetaData dbmeta = con.getMetaData();
      ResultSet dbrs = dbmeta.getPrimaryKeys(null, null, "employeetable");
      while (dbrs.next()){
      System.out.println(dbrs.getString("COLUMN_NAME"));
      }

      DataSourceUtils.releaseConnection(con,datasource);

      This is execuing sometimes and i am getting exceptions also as:

      21:03:51,585 INFO [STDOUT] org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))

      please say any solution for this problem.