Archive

Archive for the ‘Uncategorized’ Category

Operation not allowed after ResultSet closed

March 5, 2010 Leave a comment

Result sets are implicitly closed when the statement that created them are closed. Statements are implicitly closed when the connection that created them are closed.

So it is not advisable to return an ResultSet for the method.

public ResultSet executeDBQuery(){
// try block
//Establish Connection connection = DriverManager.getConnection(url, userName, password);
//Statement st = connection.createStatement();
//resultSet = st.executeQuery(dBQuery);
//ResultSet will not contain any details if the connection is closed.
//Close connection
//return resultSet
}

Alternative :
public ResultSet executeDBQuery(){
// try block
//Establish Connection connection = DriverManager.getConnection(url, userName, password);
//Statement st = connection.createStatement();
//resultSet = st.executeQuery(dBQuery);
//do not close the connection
//return resultSet
}

ResultSet rs = DB..executeDBQuery()
//Now Close the connection

-Ram

Categories: Uncategorized

Difference between JPA and hibernate

February 25, 2010 Leave a comment

Java Persistence API (JPA) is a standardized API for persistence in Java.

Hibernate is an implementation of JPA, as well as OpenJPA is another JPA implementation. Each implementation has specific features to extend the JPA functionalities.

JPA is a spec and not an implementation, so if you choose JPA, you still have to pick an implementation. You can pick Hibernate, Toplink, and any other ORM that implements JPA.

-Ram

Categories: Uncategorized

‘xcopy’ is not recognized as an internal or external command

February 22, 2010 Leave a comment

System32 folder might be missing from the PATH environmental variable. Please place this folder in the system path variable.

My Computer -> properties -> advanced ->Environment Variable

Now open a new window and then execute the command.

-Ram

Categories: Uncategorized

Difference between javac and JIT

February 5, 2010 Leave a comment

Java compiler compiles source files (.java) to bytecode files (.class). Sun gives a free java compiler which is invoked with the ‘javac’ command.

A java interpreter is usually referred to as the Java Virtual Machine (or JVM). It reads and executes the bytecodes in the .class files.  Sun also supplies a free version of the JVM which is invoked with the ‘java’ command.

Where we get confusing is when people talk about a Just-In-Time compiler (or JIT compiler). This is actually part of a JVM. Its purpose is to take the generic (i.e. cross-platform) bytecodes and compile them into more machine-specific instructions (allowing the program to run significantly faster). Even though it is referred to as a JIT ‘compiler’, it is part of the Virtual Machine.

Now, this is what every JVM is facing: should it further translate those byte codes (using that JIT compiler) or should it interpret (or execute) these things itself? JIT compilation is just what it says: just in time compilation. Facing the choice of interpreting those byte codes itself (being slow) or compiling it into real machine code (by activating the JIT compiler) first and then let the real processor do the job, so the real machine code could get executed (or interpreted) by the real CPU is quite a choice to make.

-Ram

Categories: Uncategorized

antiJARLocking attribute set to true in the context xml

February 4, 2010 Leave a comment

If the antiJARLocking attribute is set to true in the context xml, the files contained in the jars will get loaded in the work\_\loader folder of tomcat and if the antiJARLocking attribute is not set to true then the loader folder will not be cretaed in work\_\ folder and also  the files(properties …etc) will be referred from the appropriate jar only.

It is good not to set the antiJARLocking attribute to true in the production environment.

-Ram

Categories: Uncategorized Tags:

How to alter JBoss deployment order

September 17, 2009 Leave a comment

If one application depends on another one  — you may want to alter the deployment order of JBoss.

1. One way to accomplish this is to change the order in the ${serverconfig}/conf/xmdesc/org.jboss.deployment.MainDeployer-xmbean.xml file.

<attribute access=’read-write’ setMethod=’setEnhancedSuffixOrder’ getMethod=’getEnhancedSuffixOrder’>
   <description>Allows the override of the suffix order declared by subdeployers, using the syntax [order:]suffix
   </description>
   <name>EnhancedSuffixOrder</name>
   <type>[Ljava.lang.String;</type>
   <descriptors>
      <value value=”250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,650:.ear,800:.bsh”/>
   </descriptors>
</attribute>

2. One way to accomplish this is to create a deploy.last directory inside the deploy directory and put the application that needs to be deployed after the other in the deploy.last directory.

Another one is to modify ${serverconfig}/conf.xmdesc/org.jboss.deployment.MainDeployer-xmbean.xml
and add your application before the othes in the EnhancedSuffixOrder list.

<attribute access=’read-write’ setMethod=’setEnhancedSuffixOrder’ getMethod=’getEnhancedSuffixOrder’>
   <description>Allows the override of the suffix order declared by subdeployers, using the syntax [order:]suffix
   </description>
   <name>EnhancedSuffixOrder</name>
   <type>[Ljava.lang.String;</type>
   <descriptors>
      <value value=”250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,600:mynewapp.ear,650:.ear,800:.bsh”/>
   </descriptors>
</attribute>

Categories: Uncategorized Tags: ,

Read and write a Properties file

May 21, 2009 Leave a comment

// Read properties file.
Properties prop = new Properties();

try {
prop.load(new FileInputStream("filename.properties"));
} catch (IOException e) {
}


// Write properties file.
try {
prop.store(new FileOutputStream("filename.properties"), null);
} catch (IOException e) {
}


Categories: Uncategorized