Weblogic 数据源及连接池配置问题Warning! Connectivity to backend database not verified

Warning! Connectivity to backend database not verified 

JDBC Connection Pool 测试出现异常:

Warning! Connectivity to backend database not verified. This is either because required connection pool attributes "TestConnectionsOnReserve" or "TestConnectionsOnRelease" have not been enabled, or an invalid value has been specified for attribute "TestTableName". Please check the server log for more details

 

解决方法:weblogic的控制台中,配置pool完毕后要选择Test Reserved Connections,Test Table Name默认即可

 

代码中可先用JDBC连接,测试成功再用配置的数据源连接测试。。

public static Connection getConnection(){ Connection conn = null; String url = "jdbc:postgresql://192.168.0.180/getseus"; String userName = "getsdbadmin"; String pwd = "powerdb"; try { Class.forName("org.postgresql.Driver").newInstance(); conn = DriverManager.getConnection(url,userName,pwd); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (Exception e){ e.printStackTrace(); } return conn; } public static Connection getConnectionFromDS(){ Connection conn = null; Context ctx = null; try { ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("JNDIPG"); conn = ds.getConnection(); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return conn; }

你可能感兴趣的:(WEB服务器)