Versha Agarwal

Ranch Hand
+ Follow
since Oct 14, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Versha Agarwal

Finally Removing 'classes12.jar'  from classpathh solved the issue.
But now ArrayDescriptor.createDescriptor () is deprecated. I have to struggle with that.
Thank You all for your support.
4 days ago

I understand your view. But it is difficult to change ConnectionPooler class at the moment.
and the solution given again require  to convert

'OracleConnection spConn' from 'Connection conn'
(
)

So the problem remains same.
4 days ago


At this line it gives exception 'java.lang.ClassCastException: com.sun.proxy.$Proxy9 cannot be cast to oracle.jdbc.OracleConnection'  that means OracleConnection is needed

and when I inspect

it returns
oracle.jdbc.driver.T4CConnection@12299890

and
prototype and explanation of unwrap is :

unwrap(Class <T> iface): T - Wrapper

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
If the receiver implements the interface then the result is the receiver or a proxy fo
eceiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object.
Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result.
If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.
Parameters:<T> the type of the class modeled by this Class objectiface A Class defining an interface that the result must implement
.Returns:an object that implements the interface. May be a proxy for the actual implementing object.Throws:java.sql.SQLException - If no object found that implements the interfaceSince:1.6

5 days ago
Here is code for  ConnectionPooler.java
5 days ago
When I use Connection conn from ConnectionPooler I get erroe nessage as below


and when I try to convert it to OracleConnection

it gives 'not a wrapper class'

I have tried with  ojdbc7.jar  & ojdbc8.jar in C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib folder
6 days ago
Thank you all for quick reply. But I have already tried above solutions. Nothing worked
1 week ago
This code works fine if I run it directly from public static void main() method using

Class.forName("oracle.jdbc.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:url ","DB","DB");
1 week ago


I want to send array of integer and retrieve array of sturct  from Oracle Procedure.
but I get Error:   "java.sql.SQLException: Not a wrapper of oracle.jdbc.driver.OracleConnection"
Environment is:
oracle Export: Release 11.2.0.1.0
Apache Tomcat/8.0.37
Struts 1.1
Java 1.8
JDBC driver version is 10.1.0.2.0
SERVER.XML
<Resource name="jdbc/db" auth="Container" type="oracle.jdbc.pool.OracleDataSource"  accessToUnderlyingConnectionAllowed="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
username="USER" password="password" maxTotal="20" maxIdle="10"  maxWaitMillis="-1"
  driverClassName="oracle.jdbc.OracleDriver"  url="URL" />
My Code is
public SalryHdrDTO getFacWrkingDays(SalryHdrDTO objSalryHdr ) throws HrisException{
this.logger.info(SalryDAO.class.getName() + " --->> getFacWrkingDays() Starts");
Connection conn = null;
try {
conn = this.connectionPoolerObj.getConnection(); //from JNDI
if (conn != null){

if (objSalryHdr !=  null){
int[] multiFacId = objSalryHdr.getMultiFacId();
final String typeName = "HRIS.FAC_OBJ"; //created in database
final String typeTableName = "HRIS.ARR_FAC_OBJ"; //created in database
OracleConnection oConn=null;
//if (conn.isWrapperFor(OracleConnection.class)) {
//ERROR :  java.sql.SQLException: Not a wrapper of oracle.jdbc.driver.OracleConnection
// if I use "oracle.jdbc.OracleConnection.class" it gives compilation error
oConn = conn.unwrap(OracleConnection.class);
//}
ArrayDescriptor des = ArrayDescriptor.createDescriptor("HRIS.ARR_FAC_ID", oConn);
ARRAY arr_fac = new ARRAY(des,conn,multiFacId);

final StructDescriptor structDescriptor = StructDescriptor.createDescriptor(typeName.toUpperCase(), oConn);
final ResultSetMetaData metaData = structDescriptor.getMetaData();

CallableStatement st = conn.prepareCall("call HRIS.EMP_SAL_CALC.get_fac_wrking_days(?,?,?)");
// Passing an array to the procedure -
st.setArray(1, arr_fac);
st.registerOutParameter(2, Types.INTEGER);
st.registerOutParameter(3,Types.ARRAY,typeTableName);
st.execute();

System.out.println("size : "+st.getInt(2));
Object[] data = (Object[]) ((Array) st.getObject(3)).getArray();
for(Object tmp : data) {
Struct row = (Struct) tmp;
// Attributes are index 1 based...
int idx = 1;
for(Object attribute : row.getAttributes()) {
System.out.println(metaData.getColumnName(idx) + " = " + attribute);
++idx;
}
System.out.println("---");
}
st.close();
}
}
}
catch (Exception ex) {
this.logger.debug(SalryDAO.class.getName() + " getFacWrkingDays() Exception Raised --->> " + ex.getMessage());
throw new HrisException(ex.getMessage());
} finally {
this.connectionPoolerObj.returnConnection(conn);
}
this.logger.info(SalryDAO.class.getName() + " --->> getFacWrkingDays() Starts");
return objSalryHdr;
}
1 week ago

Versha Agarwal wrote:I have web application with following configuration;

Tomcat 8.0.37
Java "1.8.0_25"
Struts 1.1
oracle 11g

The web application [mmmPms] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4a3a56ec])
and a value of type [java.lang.Class] (value [class supLedgerDateWise_1477563207590_674836]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.


I already checked it for Connection, resultset, Preparedstatement
1 year ago
I have web application with following configuration;

Tomcat 8.0.37
Java "1.8.0_25"
Struts 1.1
oracle 11g

The web application [mmmPms] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4a3a56ec])
and a value of type [java.lang.Class] (value [class supLedgerDateWise_1477563207590_674836]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
1 year ago
Problem Solved.
In subject \r\n chracters was appended befor order code.
1 year ago