Friday, May 28, 2004

Further JDBC nightmares...


Well I did think that Weblogic deployment might be easier... in a way it was but I still had a nightmare getting mu DataSource visible from the JSTL SQL tags that I've got coded. After much going round the houses, using the Weblogic admin console (since I naively thought that I could just use that)... I think it turned out that I needed a resource-ref element and/or a context-param element in the web.xml. Not quite sure anymore (and I can't be arsed to go back and retry it all), but I think it was the resource-ref that was missing, or wrong.

It ended up like this:

<resource-ref>
<res-ref-name>myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Labels:

Monday, May 24, 2004

jdbc Nightmares


I have been having a total nightmare trying to get my JDBC DataSource configured right. This is under Tomcat 5 - I started out apparently OK but then it seemed to stop working and I couldn't get it back. I could not figure out what had changed - coz obviously something had. After much mucking around it is working again, but not quite how I expected. Here are some things to check anyway:


  • Make source your Resource and Resource-Parameter definitions are inside the Context that you want to use them in. It doesn't seem to work if they are in the GlobalNamingResources, even if you have a ResourceLink which points to them.


  • There's all sorts of confusion out there on configuring Tomcat JDBC - if a Google search is anything to go by - several people complainining about the same thing but maddeningly no clear solutions posted!


  • I am trying to connect to an Oracle database so I thought that I would use the thin client driver - but I got Oracle crashes (ORA-0600 errors)... so I ended up using the OCI driver for now, but I'm not convinced this is going to work if the server I deploy the code on doesn't have the Oracle Client Installation (OCI)...


  • For the query, I am using the JSTL SQL tags: make sure you know when to put "${DBName}" and when to put just "DBName" !! I thought it should be ${DBName}, but I just got "DataSource is null". DBName on its own did OK though... I can't be bothered to think thru why this is though...


  • I seemed to go round and round for ages just not understanding why I could see my database if I coded up JNDI searches and asked to see names in java:comp/env, but I just couldn't connect.... that's another thing which Tomcat doesn't seem to do in a very intuitive way... let's hope Weblogic is clearer!!




Enough droning.

Labels: