[阅读: 416] 2006-06-20 06:55:38
private static Connection getConnection(String jndiName) throws SQLException
{
try
{
InitialContext ctx = new InitialContext();
datasource = (DataSource)ctx.lookup("java:comp/env/"+jndiName);
return datasource.getConnection();
}
catch (javax.naming.NamingException ex)
{
ex.printStackTrace();
throw new SQLException("can not get a datasource for " + jndiName);
}
}