1 23 24 package com.sun.gjc.spi; 25 26 import com.sun.gjc.spi.ManagedConnection; 27 import java.sql.SQLException ; 28 import javax.resource.ResourceException ; 29 30 import com.sun.logging.*; 31 import java.util.logging.Logger ; 32 import java.util.logging.Level ; 33 39 public class ManagedConnectionMetaData implements javax.resource.spi.ManagedConnectionMetaData { 40 41 private java.sql.DatabaseMetaData dmd = null; 42 private ManagedConnection mc; 43 44 private static Logger _logger; 45 static { 46 _logger = LogDomains.getLogger( LogDomains.RSR_LOGGER ); 47 } 48 private boolean debug = false; 49 55 public ManagedConnectionMetaData(ManagedConnection mc) throws ResourceException { 56 try { 57 this.mc = mc; 58 dmd = mc.getActualConnection().getMetaData(); 59 } catch(SQLException sqle) { 60 _logger.log(Level.SEVERE, "jdbc.exc_md"); 61 throw new ResourceException (sqle.getMessage()); 62 } 63 } 64 65 72 public String getEISProductName() throws ResourceException { 73 try { 74 return dmd.getDatabaseProductName(); 75 } catch(SQLException sqle) { 76 _logger.log(Level.SEVERE, "jdbc.exc_eis_prodname", sqle); 77 throw new ResourceException (sqle.getMessage()); 78 } 79 } 80 81 88 public String getEISProductVersion() throws ResourceException { 89 try { 90 return dmd.getDatabaseProductVersion(); 91 } catch(SQLException sqle) { 92 _logger.log(Level.SEVERE, "jdbc.exc_eis_prodvers", sqle); 93 throw new ResourceException (sqle.getMessage(), sqle.getMessage()); 94 } 95 } 96 97 104 public int getMaxConnections() throws ResourceException { 105 try { 106 return dmd.getMaxConnections(); 107 } catch(SQLException sqle) { 108 _logger.log(Level.SEVERE, "jdbc.exc_eis_maxconn"); 109 throw new ResourceException (sqle.getMessage()); 110 } 111 } 112 113 121 public String getUserName() throws ResourceException { 122 javax.resource.spi.security.PasswordCredential pc = mc.getPasswordCredential(); 123 if(pc != null) { 124 return pc.getUserName(); 125 } 126 127 return mc.getManagedConnectionFactory().getUser(); 128 } 129 } 130 | Popular Tags |