Kurinchi Blogger Scribbles …


Posts Tagged ‘java’

Mar 17
2013

How to fix Hibernate MySql connection timeout issue (solved)?

Last updated: June 14th, 2013

When we began creating an application using Struts2 framework with Hibernate and MySQL, we ran into a problem which was related to MySQL timing out its connection after a span of 8 hours when left unused. It conceived a lot of time at our end but we were able to nail down the issue at the end.

Steps that we had taken to correct the issue related to Hibernate MySql connection timeout problem are listed below

– Download Hibernate C3P0 and copy .jar files
– Set c3p0.properties
– Make changes to hibernate.cfg.xml
– Test MySQL connection timeout
– Hibernate, MySQL connection timeout related error messages
(more…)

Nov 15
2012

How to setup Apache Tomcat, Java on CentOS?

Last updated: November 13th, 2012

Below set of steps involve setting up Tomcat 6 on CentOS 5 with Java 1.6

Download Apache Tomcat

$ wget http://apache.parentingamerica.com/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.tar.gz

Go to opt/ folder and extract Tomcat

$ cd /opt

$ tar -xzf apache-tomcat-6.0.36.tar.gz

Create a tomcat user

$ useradd -d /opt/apache-tomcat-6.0.36/ tomcatuser

Change user permission on tomcat folder

$ chown -R tomcatuser:tomcatuser apache-tomcat-6.0.36
(more…)

Nov 14
2012

How to install java 6 on CentOS 5 and remove other JDK, JRE version?

Last updated: November 13th, 2012

At the time of writing this article Java 6 (update 37) was available at http://www.java.com/en/download/manual_v6.jsp

First set up a folder where you want to install java

$ cd /opt

$ wget http://download.oracle.com/otn-pub/java/jdk/6u37-b06/jdk-6u37-linux-x64-rpm.bin

$ chmod +x jdk-6u37-linux-x64-rpm.bin

$ ./jdk-6u37-linux-x64-rpm.bin
(more…)

Nov 13
2012

How to check, remove JRE, JDK, OPENJDK installation?

Last updated: November 12th, 2012

To check the current installation of java

$ rpm -qa | grep jre

$ rpm -qa | grep jdk

$ rpm -qa | grep openjdk

To remove the java installs

$ yum erase jre jdk openjdk

Oct 30
2012

Java Tomcat – SEVERE: Catalina.stop: java.net.ConnectException: Connection refused

Last updated: November 13th, 2012

This error pops up when you try to stop the Tomcat server when the server has not started. If you restart the Tomcat server, the error vanishes.

Oct 07
2012

Java: Buffered Reader Vs. Scanner

Last updated: October 7th, 2012

Buffered Reader
– Buffered reader reads text from a character input stream and buffers those characters
– Buffered reader has a buffer size of 8 KB
– Buffered reader is synchronized and can be safely called from multiple threads
– To parse for primitive data types additional functions needs to be called

Scanner
– Scanner breaks down input into tokens and translates individual tokens according to their data type
– Scanner has a buffer size of 1KB
– Scanner is not synchronized
– Scanner can parse for primitive types and strings using regular expressions

Source:
http://docs.oracle.com/javase/6/docs/api/java/io/BufferedReader.html
http://docs.oracle.com/javase/tutorial/essential/io/scanning.html

May 20
2011

JAVA: public class naming

Last updated: January 2nd, 2012

A JAVA program file can only contain one public java class and this should be named the same as the java file itself.

There can be any number of classes with / without other modifiers.

Classes without any modifiers will get compiled even if the name of the class does not match the name of the java program file.
(more…)

Feb 15
2011

Netbeans: Authentication required dialog box requesting user name and password

Last updated: March 13th, 2011

If a user role and his credentials are not set or is incorrect for Tomcat startup via NetBeans IDE you will get this dialog box opened

i) First check the Netbeans configuration settings Open Tools > Server

ii) Base path for Catalina will be set in the General tab andn it will be of the form \CATALINA_BASE\conf\tomcat-users.xml. Check if a user and his role is defined as stated in the below syntax. If not add these lines

<role rolename=”manager”/>
<user username=”tomcat” password=”secured” roles=”manager”/>

iii) In Tools > Server > General tab enter the username and password stated in the tomcat-users.xml file and this will stop the Netbeans IDE from asking you the name and password

Feb 14
2011

To debug struts, add the below line in the struts.xml file

Last updated: March 13th, 2011

//struts.xml
<struts>
<constant name=”struts.devMode” value=”true” />
…..
</struts>

Feb 13
2011

Netbeans: HTTP Status 404 – There is no Action mapped for namespace / and action name

Last updated: March 13th, 2011

i) Check where struts.xml is defined – Path where the file exists. In netbeans, easy way to do this to add the struts.xml file to package folder.

ii) Check if the correct namespace is added in the struts.xml

iii) Check if the package name is given correctly for the class in execution.


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict