Help coderanch get a
new server
by contributing to the fundraiser

Nagendra Batchu

Ranch Hand
+ Follow
since Jan 23, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Nagendra Batchu

Hi

How to delete the data from huge table, For example if table called Warehouse contains data about 9 cores, then what is the best way to delete around 4 cores of data.


Please suggest


14 years ago
Hi,

I am using connection pooling in tomcat 5.5 the following changes i had in the respective files.

In Server.xml

<Context path="/SMS" docBase="SMS" debug="0"
reloadable="false" override="true">
<Resource name="jdbc/DefaultDS" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DefaultDS">
<parameter><name>user</name><value>cdmsprod</value></parameter>
<parameter><name>password</name><value>cdmsprod</value></parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter>
<name>driverName</name>
<value>jdbc:oracle:thin:@172.18.109.126:1521:DMSDB</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>8</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>6</value>
</parameter>
</ResourceParams>
</Context>

3. Add the follwing tag in the web.xml file:

<resource-ref>
<res-ref-name>jdbc/DefaultDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

4. Add following code in the JSP file:

InitialContext jndiCntx = new InitialContext();
Context ctx=(Context)jndiCntx.lookup("java:comp/env");
System.out.println("Looking up jdbc/DefaultDS");
ds = (javax.sql.DataSource)ctx.lookup("jdbc/DefaultDS");
System.out.println("Found");


5.In META_INF/context file add the following contants

<?xml version='1.0' encoding='utf-8'?>
<Context path="/SMS" debug="1" reloadable="true"
docBase='${catalina.home}/server/webapps/SMS'>
<Resource name="jdbc/DefaultDS" auth="Container"
type="javax.sql.DataSource" username="cdmsdvlp" password="cdmsdvlp"
driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@172.18.109.126:1521:DMSDB"
maxActive="8" maxIdle="4" maxWait="4"/>

</Context>

It is working fine if we send one request at a time , if the number of users exceeds 5 then the following exception is coming

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
org.apache.jsp.recieveSMS_jsp._jspService(recieveSMS_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Please suggest
14 years ago
Thanks for your reply,

But even if i comment the below lines

<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Manager pathname="" />

still its not working.

Please suggest.



14 years ago
In the Logs it displays as

javax.servlet.ServletException: Name java: is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.recieveSMS_jsp._jspService(recieveSMS_jsp.java:368)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.naming.NameNotFoundException: Name java: is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
javax.naming.InitialContext.lookup(Unknown Source)
org.apache.jsp.recieveSMS_jsp._jspService(recieveSMS_jsp.java:67)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

14 years ago
Hi,

I need to get the DB connection object from the data source using tomcat 5.5 server.

1 Step: Added classess12.jar in E:\Tomcat 5.5\common\lib folder
2 Step:Added resource tag in the context.xml file

The context.xml file is as follows:

<Context>

<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Manager pathname="" />
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@172.18.109.126:1521:CDMSDB"
username="cdmsdvlp" password="cdmsdvlp" maxActive="20" maxIdle="10"
maxWait="-1"/>

</Context>

3 Step: Added resource tag in web.xml , The resource tag is as follows:

<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

4 Step: The following code used in the jsp :

Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection con = ds.getConnection();

Please help me in solving the above mentioned problem.
14 years ago
Thanks for your reply,

To my knowledge we can read the file using UTL_FILE package from the server, But my requirement is to read the file from local system.


Please suggest some sample code for Reading the file .


Thanks in Advance
14 years ago
hi Friends,

I have to write a stored procedure to read a text file from c:/fileData directory and insert each row as a record in the oracle table.

Please help me in solving this problem.

Thanks in Advance
14 years ago
Hi,

I am currently trying to convert one of our existing module to hibernate (For POC).
In this process, i require all our existing sql queries to be converted to hibernate based queries.

Could any one please help me (as im new to hibernate) by giving example to convert the following existing sql query to hibernate native query?
(Please note that: i have already created separate DAO layer and created session object as well).

Example query(query includes subquery as well):

SELECT EL5, ELMADDRTAG, VALUEDOC, VALUEDOC_DP, CHECKEDSTATUS, SEQNO,
(SELECT COUNT(1) FROM [820LDEV1].CSD_CHEQUE_TRANS WHERE CSD_CHEQUE_TRANS.SEQNO = CSD_CHEQUE_HEADER.SEQNO)
FROM [820LDEV1].CSD_CHEQUE_HEADER
WHERE CSD_CHEQUE_HEADER.CMPCODE = ? AND CSD_CHEQUE_HEADER.PRINTSTATUS = 0 AND CSD_CHEQUE_HEADER.EL5 <> ''

Where
820LDEV1 -> schema name.
EL5, ELMADDRTAG, VALUEDOC, VALUEDOC_DP, CHECKEDSTATUS, SEQNO -> column names.
CSD_CHEQUE_HEADER,CSD_CHEQUE_TRANS -> are tables.

How can i represent this schema name in hibernate query?
session.? (which method of session is most preferable here).

Any related help is most helpful for me.

Thanks in advance for your kind help.
Thanks Paul.

Thanks for your information.
I am still in initial stage of my work (POC). So, let me change the version now itself and see whether this error still persist.!!!

Could you suggest any site or technical stuff related to steps involved in incorporating hibernate into existing project(module)?

Any related information would be great helpful.

thanks a lot.
I am currently working on hibernate POC. I am trying to convert one of the our existing module to use hibernate.
I am just taking the help from following examples http://www.laliluna.de/struts-hibernate-integration-tutorial-en.html.

Cann't we proceed with hibernate2? Is this error is specific to version?


thanks.
Hi,
i am new to Hibernate.
I am trying to get the current session from the HibernateSessionFactory. I am getting following exception.
Could any one kindly help me in this?
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: could not instantiate id generator
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:82)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:644)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:690)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at com.rm.juno.chequepayments.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:50)
at com.rm.juno.chequepayments.server.dao.ChequePaymentsHibernateDAO.fetchTransactionListForChqPrinting(ChequePaymentsHibernateDAO.java:334)
at com.rm.juno.chequepayments.server.br.ChequePaymentsBaseBR.fetchTransactionListForChqPrinting(ChequePaymentsBaseBR.java:1063)
at com.rm.juno.chequepayments.server.br.ChequePaymentsBaseBR.fetchDataChqForPrintingTab(ChequePaymentsBaseBR.java:831)
at com.rm.juno.chequepayments.server.stub.ChequePaymentsStub.fetchDataChqForPrintingTab(ChequePaymentsStub.java:181)
at com.rm.juno.chequepayments.web.delegate.ChequePaymentsDelegate.fetchDataChqForPrintingTab(ChequePaymentsDelegate.java:141)
at com.rm.juno.chequepayments.web.action.ChequePaymentsAction.processShowChequesForPrinting(ChequePaymentsAction.java:546)
at com.rm.juno.chequepayments.web.action.ChequePaymentsAction.showChequesForPrinting(ChequePaymentsAction.java:525)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.rm.juno.JunoFilter.doFilter(JunoFilter.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:76)
... 43 more

thanks in advance for help.
Thanks fo your valuable response ..I will try removing the indexes on the column..Thanks a lot
Hi All,

I am facing a problem in Using Update query in prepared statement. I am trying to update a huge set of records by using Prepared Statement in JAVA


The Code is as follows:


statement5=connection.prepareStatement("update CHANNELINVENTORY set CHANNELCODE=?,LASTUPDATEON=sysdate where UPPER(ITEMCODE)=? and UPPER(SERIALNUMBER)=? ");
for(int j=0;j<channelInventoryDetails.size();j++){
String channelDetails=(String)channelInventoryDetails.get(j);
String[] channel=channelDetails.split("-");
statement5.setString(1,channel[0]);
statement5.setString(2,channel[1]);
statement5.setString(3,channel[2]);
if (j > 0 && j % 1000 == 0){
System.out.println("before addbatch-from if->"+j);
statement5.addBatch();
statement5.clearParameters();
statement5.executeBatch();
}else{
System.out.println("before addbatch-from else->"+j);
statement5.addBatch();
statement5.clearParameters();
}
}

In my present case i am trying to update around 3000 records, in my code after every 1000 records i am executing that batch , which is taking huge time ...nothing is coming its just hanging for huge time .. its just prints this ------------------->before addbatch-from if->1000 thats it

And in the DB there primary key constaints on both the (ITEMCODE+SERIALNUMBER) and there is a index on CHANNELCODE..

Please suggest me the changes...

Is this the right way to update huge data in the table ...or is there any other way to update huge data.



Hi All,

When i am updating some records(say 3000) through java code, then after all the transaction gets comitted, i am get the follows exception and system getting stopped.

The Exception error is as follows:

log4j:ERROR Error occured while converting date.
java.lang.NullPointerException
at java.lang.System.arraycopy(Native Method)
at java.lang.AbstractStringBuilder.getChars(Unknown Source)
at java.lang.StringBuffer.getChars(Unknown Source)
at org.apache.log4j.helpers.ISO8601DateFormat.format(ISO8601DateFormat.java:130)
at java.text.DateFormat.format(Unknown Source)
at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:444)
at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:502)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:302)
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:263)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:160)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:253)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
14 years ago
Hi Friends,

i wrote one stored procedure in oracle, i need to call the stored procedure for every 5min. How can i create the job for this in oracle8.0.

I am using TOAD, in toad they give one option to create the job. But i don't know how to configure it in the TOAD could any body please help me to solve the problem.
15 years ago