• Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

Comments (13)

1 localhost commented Trackback

Can you try it "my way", with the Context in server.xml? Even if it isn't practical for you to deploy that way, it would be interesting to see if it can work for you if we try the same thing.Guy

2 localhost commented Permalink

that seems to make a good bit of a difference (for Informix anyway.) instead of returning NULL this statement...

DataSource ds = (DataSource)envContext.lookup("jdbc/Informix");
now returns a "BasicDataSource". so far so good, but on the next line...
conn = ds.getConnection(user, pw);
throws an UnsupportedOperationException "Not supported by BasicDataSource".

3 localhost commented Trackback

Hi, the Informix Database version could be very relevant here. Please find out what it is.

4 localhost commented Permalink

just found out.....v10

5 localhost commented Permalink

wanted to show you my web.xml file...

Connection to the DB<!--res-ref-name>jdbc/Oracle</res-ref-name-->jdbc/Informixjavax.sql.DataSourceContainer

6 localhost commented Trackback

V10 should be ok.

I just took a look at one of my working connection pools on Solaris (close enough). You didn't show me your "Context" definition in server.xml, here's my Context and embedded Resource definition (for an application called quiz) in server.xml (excuse lack of formatting):
Here's my corresponding web.xml code in webapps/quiz/WEB-INF: Quiz Datasource jdbc/quiz javax.sql.DataSource Container
and here's the code that calls it in the application:
import java.sql.*;import javax.naming.*;import javax.sql.*;Context initContext = new InitialContext();Context envContext = (Context) initContext.lookup("java:/comp/env");DataSource ds = (DataSource) envContext.lookup("jdbc/quiz");.....
Connection con = ds.getConnection();

7 localhost commented Permalink


i don't have a "context" definition in server.xml, i am using "context.xml" under my WebRoot/META-INF directory. other than that i have exactly what you have. Oracle works, Informix doesn't. the line....
DataSource dsInformix = (DataSource)envContext.lookup("jdbc/Informix");
always returns null. switching "Informix" to "Oracle" the datasource is valid...surprising since "jdbc/Oracle" isn't listed in web.xml.
the only other way i have found to do this is....IfxConnectionPoolDataSource cpds = new IfxConnectionPoolDataSource();
cpds.setIfxIFXHOST("redhat01.alex.robbinsgioia.com");cpds.setPortNumber(9088);cpds.setUser("informix");cpds.setPassword("informix1");cpds.setServerName("redhat01");cpds.setDatabaseName("acrs");cpds.setIfxGL_DATE("%B %d, %Y");conn = cpds.getPooledConnection().getConnection();
works. clearly it isn't using JNDI, but a connection is a connection.

8 localhost commented Permalink

I finally got this to work....but since the returning datasource is BasicDataSource i cannot do...

Connection conn = dataSrc.getConnection(userId, pw);
i tried changing "type=javax.sql.DataSource" to "type=com.informix.jdbcx.IfxConnectionPoolDataSource" but that caused it to barf.
i really need the userid/pw to NOT be in server.xml (as that is not quite as secure as we'd like!)

9 localhost commented Permalink

There seem to be two options after talking to some people.

1) import com.informix.jdbcx.IfxDataSource; and use IfxDataSource.getConnection(uid , pwd)to get a connection
2) import com.informix.jdbcx.IfxConnectionPooledDataSource; and use IfxConnectionPooledDataSource.getPooledConnection(uid, pwd).getConnection() to get a connection
Apparently IfxConnectionPooledDataSource doesn't support getConnection(uid , pwd).
Sorry about the trouble.

10 localhost commented Permalink

i think you guys need to run your example and verify that it works. as far as i can tell specifying Resource type="javax.sql.DataSource" will only return a BasicDataSource object. that datasource is not capable of interacting with a database. there seems to be no way to cast it to an informix datasource either.

again, the only way i could get this to work, not using JNDI, is...
cpds.setIfxIFXHOST("myserver.mycompany.com"); cpds.setPortNumber(9088); cpds.setUser("informix"); cpds.setPassword("informix1"); cpds.setServerName("redhat01"); cpds.setDatabaseName("acrs"); cpds.setIfxGL_DATE("%B %d, %Y"); conn = cpds.getPooledConnection().getConnection();

11 localhost commented Permalink

Forgive me for not being familiar using Tomcat with JDBC.

Your code: conn = cpds.getPooledConnection().getConnection();
This example did not work?conn = cpds.getPooledConnection(id, pwd).getConnection();
I am also asking around for help. I will get back to you.

12 localhost commented Permalink

Yes, "conn = cpds.getPooledConnection().getConnection();" does get a connection.

however, the thrust of this article appears to tell users how to get a connection from a pool via JNDI (with a RESOURCE specified in server.xml). i had no luck whatsoever with any (and all) variation of the original RESOURCE to get a connection. certainly not type=javax.sql.DataSource, not even type=com.informix.jdbcx.IfxConnectionPoolDataSource which seems more logical.
my app works with the non-JNDI connection pool..it would have been nice to use JNDI.

13 localhost commented Permalink

Regarding your first post, how did you insert in the user and password for Oracle?

Add a Comment Add a Comment