Thursday, October 23, 2008

“Error (n, m): identifier OracleJspRuntime not found”
- Jdeveloper Error.

You might have noticed this error sometimes in your Project.

The solution to this error is simple – you just need to add Jdeveloper’s “JSP Runtime” standanrd library to your Project Classpath – here are the steps to do it in Jdeveloper 10.1.3 : -

1. Right click on the Project & select the “Project Properties” option.
2. You can see the “Project Properties window.
3. Select the “Libraries” option. You can see the various configuration options for Project Libraries.
4. Click on the “Add Library” button. You can see the “Add Library” window.
5. Select “JSP Runtime” from the list of libraries & click on the “Ok” button.
6. “Make” / “Rebuild” your project.
7. You can see that you no longer see this error.


Thanks once again to the people who have discussed this at Oracle Technology Network Forums & various Bloggers who have spoken about it.

I am just posting this in my Blog for my reference.

JDeveloper JSP files must reside in the server root directory or a subdirectory

“Error: JSP files must reside in the server root directory or a subdirectory”

- Jdeveloper Error

How often have you struggled to specify a different folder for your JSPs, instead of JDeveloper’s default folder “public_html”?

I struggled with this option today – I inherited an application source code that I had to analyze & look our for ways to improve readability of the code. The application source code had been developed without an IDE (!), using our favorite ANT as the build tool.

I easily imported this code into Jdeveloper 10.1.3 (using NEW -> Project from Source Code). However, I noticed that I frequently hit the error mentioned above.

After Googling a bit, I stumbled upon a few OTN forum posts. I found out that the solution is rather simple.

1. Click on the “Tools” option in the Jdeveloper Menu.
2. Select the “Project Properties” option from the drop down.
You can see the “Project Properties” Window.
3. Click on the “+” in the “Web Application” section to expand the options.
4. You can see the “HTML Root Directory” option.
5. Specify the Root Directory of your JSP Pages here & click on the Ok button.
6. “Make” or “ReBuild” your project now.
7. You can notice that you no longer see this error.


The supplied JDeveloper help pages are slightly confusing – they don not mention that the “HTML Root Directory” option is present under the “Web Application” section.

Tuesday, October 14, 2008

Oracle UCP : Hello World

" The Universal Connection Pool provides an enhanced common infrastructure for database connection pooling. It is usable within the OC4J context as well as by non-Java EE applications for connecting to Oracle and non-Oracle databases and other resources like JCA and LDAP connections. "


I am exploring Oracle Universal Connection Pool for a customer engagement. I was exploring the API & came up with a basic "Hello World" style introduction for the API.

I just wanted to share it here:-


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import oracle.ucp.UniversalConnectionPoolException;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceImpl;


public class UCPHelloWorld
{

public UCPHelloWorld()
{

}// end of constructor

public static void main(String args[])
{
String strConnectionPoolName= null;
String strConnectionFactory = null;
String strDatabaseURL = null;
String strDatabaseUser = null;
String strUserPassword = null;
String strSQLQuery = null;
String strEmployeeName = null;

Connection objConnection = null;
Statement objStatement = null;
ResultSet objResultSet = null;

PoolDataSource objPoolDataSource= null;

strConnectionPoolName = "myConnectionPool";
strConnectionFactory = "oracle.jdbc.pool.OracleDataSource";
strDatabaseURL = "jdbc:oracle:thin:@localhost:1521/XE";
strDatabaseUser = "scott";
strUserPassword = "tiger";
strSQLQuery = "SELECT ENAME FROM EMP";
strEmployeeName = "ENAME";


try
{
objPoolDataSource = new PoolDataSourceImpl();

// Basic Connection Parameters
objPoolDataSource.setConnectionFactoryClassName(strConnectionFactory);
objPoolDataSource.setURL(strDatabaseURL);
objPoolDataSource.setUser(strDatabaseUser);
objPoolDataSource.setPassword(strUserPassword);
objPoolDataSource.setConnectionPoolName(strConnectionPoolName);

// Set the Pool Size
objPoolDataSource.setMinPoolSize(4);
objPoolDataSource.setMaxPoolSize(10);
objPoolDataSource.setConnectionWaitTimeout(2);
objPoolDataSource.setInitialPoolSize(4);

System.out.println("Before getting the Connection");

objConnection = objPoolDataSource.getConnection();
objStatement = objConnection.createStatement();
objResultSet = objStatement.executeQuery(strSQLQuery);

System.out.println("After getting the Connection");

while(objResultSet.next())
{

System.out.println(objResultSet.getString(strEmployeeName));

}// end of resultset

objResultSet.close();
objStatement.close();
objConnection.close();

}
catch (SQLException objSQLException)
{
objSQLException.printStackTrace();
}
}// end of main
}// end of UCPHelloWorld