Thursday, July 27, 2006

ORA-00911: invalid character

The exception was because I had a semicolon(;) after the preparedstatement query.
Removal of it resolved the problem

Tuesday, May 09, 2006

Database Explorer in Eclipse 3.1

Hi,

These are two Plugins which can be used for exploring the DB.
Hence it will reduce the dependency on PL/SQL Dev and Toad.
1. SourceForge.net: Eclipse SQLExplorer plugin
2. SourceForge.net: DBEdit Plugin for Eclipse

Installation is simple, just extract them in the plugin directory of Eclipse.
After you restart your Eclipse you can see one more Perspective(SQLExplorer/DBEdit) which will depend on which plugin you have installed.

Hopefully once we move to Eclipse 3.2 we will get all this features from the Data Tools Platform.

The  installation instruction for SQL Exlplorer are present on this link
http://www.onjava.com/pub/a/onjava/2005/05/11/sqlexplorer.html



Thursday, March 23, 2006

Cannot create JDBC driver of class '' for connect URL 'null'

If you get this Exception while using Tomcat 5.5.9 or 5.5.*
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at com.vsnl.pcr.dao.DataAccessObject.getConnection(DataAccessObject.java:119) ... 29 more

Possible Solution:
Check the database lookup entry in either context.xml or server.xml
In Tomcat 5.5.9 there are no <ResouceParams> tag and the parameters are passed alongiwth the resource tag.

e.g Resource Entry in Tomcat 5.5.9


<resource name="jdbc/XYZ"
auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
driverclassname="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:XYZ"
username="xyz"
password="xyz"
maxactive="10"
maxidle="100"
maxwait="3000">
</resource>




In Tomcat 5.0.28


<resource name="jdbc/XYZ" scope="Shareable" type="javax.sql.DataSource">
<resourceparams name="jdbc/XYZ">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:XYZ</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>xyz</value>
</parameter>
<parameter>
<name>password</name>
<value>xyz</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>

</resourceparams>
</resource>

One Last Point: Dont forget to put your classes12.jar/ojdbc14.jar file in /commons/lib folder.

Two useful links which help me discover this.. :-) (after I had already wasted a lot of time)
1. Java Forums
2. Tomcat Docs

Monday, March 13, 2006

Common Struts Errors

Common Struts Errors
A really good compilation of some Common Struts erors and I find it quite handy :-) most of the times

Wednesday, March 08, 2006

javax.servlet.ServletException: Define tag cannot set a null value

If you are using struts and get this error, it means you might have used
tag for a value which is null.

The problem would be solved if you use tag to check for the null value.
e.g.

1 <logic:notEmpty name="fooForm" property="fooList">
2 <bean:define id="fooList" name="fooForm" property="fooList" />
3 <html:options collection="fooList" property="id" labelProperty="fooname" />
4 </logic:notEmpty>

The 'fooList' is checked before being defined in the samplecode

Thursday, February 16, 2006

How to Stop double submit on click of refresh button in Struts

Follow these steps if you are using Struts
1. Add saveToken(request) in the execute() method of the Action when the page needs to displayed first or initialized.
2. Add the following code in the execute() method of Action handling the processing of the page on Submit

if (isTokenValid(request)) {
////// Do the processing for the request and add messages if required

resetToken(request); /// Reset the token so that on resubmit it does not come in this block
return mapping.findForward("success");
} else {
///// The page is submitted again so take app. action if required
return mapping.findForward("failure");
}