Tag Archives: java

Tomcat – java.lang.OutOfMemoryError


find catalina.bat and add

# for out of memory
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.

if [ -r “$CATALINA_BASE/bin/setenv.sh” ]; then
. “$CATALINA_BASE/bin/setenv.sh”
elif [ -r “$CATALINA_HOME/bin/setenv.sh” ]; then
. “$CATALINA_HOME/bin/setenv.sh”

Read more of this post

Oracle JDBC Connection – Moving from Oracle Single Instance to Oracle RAC Grid

Our core oracle database has been moved to oracle single instance to Oracle RAC Grid.

I had some old Java systems, which were using JDBC connection to connect Oracle. When system moved to RAC, my systems wasn’t working. Now, I need to change my OS host file and JDBC connection string. FYI, is my Oracle RAC’s scan ip.

For Windows,

go to C:\Windows\System32\Drivers\etc\hosts and the following entry ORACLE-RAC

for Linux,

go to /etc/hosts and add the following entry ORACLE-RAC

Done for OS part. Now the connection String.

Read more of this post

Add SSL certificate to JAVA

I needed to use SSL certificate for JavaMail. I took required SSL certificate via browsing my webmail by firefox.

Step 1 : Get the certificate

Read more of this post

Formatting Decimal Values in Java

I wanted to format my large double values in comma separated format. I took help from here.


import java.text.DecimalFormat;


public class DecimalFormatTest


private static void format(Double value, String pattern)


DecimalFormat decimalFormat = new DecimalFormat(pattern);

String output = decimalFormat.format(value);

System.out.println(value + ”  ” + pattern + ”  ” + output);


public static void main(String[] args)


format(new Double(“12345.67”), “###,##0.00”);

format(new Double(“12345”), “###,##0.00”);

format(new Double(“0”), “###,##0.00”);

format(new Double(“0”), “###,###.##”);




Sorting ArrayList in Java using Collections

I had some bit hard time sorting a list. Objects in a ArrayList contains month and year along with other properties. I want to sort that list depending on the month year combo. How i did it ??

Read more of this post

Connect to Oracle from Java via JDBC for calling Stored Procedure

My application runs on postgre. I had spring-hibernate connection from my JSF to Postgre. But, for login I needed to connect to the mother application. My core application runs on oracle. User authentication can be found through a stored procedure. I couldn’t find anything, so that I connect to databases at a time. So, took the help of JDBC. I needed the library jar for the connection to oracle. I took the ojdbc14.jar. In the stored procedure there were 5 parameters. First 2 of the are in parameter and last 2 are out parameter including one cursor. 2 IN parameter will carry the username and password and will bring back user authentication. 3rd parameter will indicate whether it is valid user (0 for valid user), 4th parameter will carry error message(if any). And if it is valid user 4th parameter will carry user related information.

String driver = “oracle.jdbc.driver.OracleDriver”;
String url = “jdbc:oracle:thin:@”;
String dbuser = “oracle”;
String dbpass = “oracle”;

Class.forName(driver); // load Oracle driver
Connection conn = DriverManager.getConnection(url, dbuser, dbpass);

String proc3StoredProcedure = “{ call usr_login_info(?, ?, ?, ?, ?) }”;
CallableStatement cs = conn.prepareCall(proc3StoredProcedure);
cs.setString(1, userName);
cs.setString(2, password);
cs.registerOutParameter(3, java.sql.Types.DOUBLE);
cs.registerOutParameter(4, java.sql.Types.VARCHAR);
cs.registerOutParameter(5, OracleTypes.CURSOR);
Double param3 = cs.getDouble(3);
String errorMessage = cs.getString(4);

User user=new User();

if (param3.equals(new Double(“0.0”)))


      ResultSet rs = (ResultSet) cs.getObject(5);
      while (rs.next())




Setting Proxy Information for maven

I was working on a J2EE app on my new work place.

I was doing the first thing for starting development… Building my frame work…

On my way I needed to connect maven repository through maven.

But I couldn’t. I was eating connection timeout error.

Suddenly I remembered, the network guys of my new workplace provided me proxy address n port and username – password to connect to the internet.

So i wanted maven to know that.

Then I googled for my problem and found some solution.

I was working on Windows XP and I installed maven in C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\

In C:\Program Files\Apache Software Foundation\apache-maven-2.2.1\conf there is a file “settings.xml”

I found the bellow block

<!– proxy
| Specification for one proxy, to be used in connecting to the network.
I just replaced it with
Then maven was able to connect to the repository.