I have been forced to switch from Tomcat to Glassfish to test web services.
During this move I have found that the way datasources in Tomcat are made
are not the same as in Glassfish. I have read that resource injection is a
good way to separate the code from the data source, but have not found
anything that identifies all the steps involved. I have attempted to create
a connection to the datasource using the @Resource annotation, but it did not
work. I then started the Glassfish admin module and created a connection
pool (named supportPool - it is pingable) and a JDBC Resource named supportdb
that uses the supportPool.
I am on a short deadline and have been trying for hours to get this working.
I am using NetBeans to create web services and the web service client. An
help would be greatly appreciated.
public class MyClass {
private @Resource(name="supportdb") javax.sql.DataSource supportDS;
public void foo() {
// At this point supportDS is null, from what I've read this should
contain a connection to the data source
Connection conn = supportDS.getConnection();
}
}
--
[Message sent by forum member 'mperemsky']
View Post: http://forums.java.net/node/834165