[jboss-user] [EJB/JBoss] - Jboss complaining about jdbc connections not being closed

sgb77 do-not-reply at jboss.com
Wed May 2 17:07:27 EDT 2007


Hello, I have a session ejb where I explicitly open and close a connection to my database, yet when I call that ejb and a result is returned the server complains about my connection not being closed.
Here is my EJB

userObj usr = new userObj();
		if (userid.equals(null) | userpasswd.trim().equals("")) {
             	return null;
		}
		String sql = "select * from users " +
			"where userid = '" + userid + "' " +
			"and userpasswd = '" + userpasswd + "'";
		try {
			Context ctx = new InitialContext();
			DataSource ds = (DataSource)ctx.lookup("java:/support");
			Connection con = ds.getConnection();
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			
			if (rs.next()) {
				usr.setEmail(Utils.convertNull(rs.getString("usremail")));
				usr.setClearance(Utils.convertNull(rs.getString("userclearance")));
				usr.setAcro(Utils.convertNull(rs.getString("useracro")));
				usr.setName(Utils.convertNull(rs.getString("username")));
				usr.setLname(Utils.convertNull(rs.getString("userlname")));
			} else {
				usr = null;
			}
			
			con.close();
			ctx.close();
			stmt.close();
		} catch (javax.naming.NamingException _ne) {
			System.out.println("DataSource: Naming Exception!");
		} catch (java.sql.SQLException _se) {
			System.out.println("SQL Exception: " + sql);
		} finally {
		
			return usr;
		}
	}

AND here is part of the error message
Thanks in advance for any help..

16:44:43,918 INFO  [CachedConnectionManager] Closing a connection for you.  Plea
se close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection at 3bbcfd

java.lang.Throwable: STACKTRACE
        at org.jboss.resource.connectionmanager.CachedConnectionManager.register
Connection(CachedConnectionManager.java:290)
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
onnection(BaseConnectionManager2.java:417)
        at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
nManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
        at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp
erDataSource.java:88)
        at hd.ejb.HelpDeskBean.Login(HelpDeskBean.java:92)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4042633#4042633

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4042633



More information about the jboss-user mailing list