Results 1 to 8 of 8
Thread: Datasource problem
- 09-21-2009, 07:55 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Datasource problem
Hi all ,
I am using TCL file with multiple queries as input to the web services.
From following statement I am getting always (like multiple tcl client ) getting single
con object.
conn = ServiceLookUp.getInstance().getDataSource(config). getConnection();
**** ServiceLookUp class is single tone class .
********** My Resource tag in server.xml file
<Resource name="jdbc/test"
auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSour ceFactory"
maxActive="30"
maxIdle="10"
maxWait="10000"
url="jdbc:oracle:thin:@***.***.***.***:1521:MCSTEM P"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="mcstest"
password="mcstest"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />
Let me know how to get the different object instead of getting single object
Please do need full, Thanks
- 09-21-2009, 08:57 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
I don't understand. Do you want to have many connections returned? Why?
- 09-21-2009, 11:06 AM #3
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
If I am running multiple tcl clients , I am getting the resultset exhausted and connection already closed errors.
Because of same object is sharing the multiple tcl clients. One tcl is closed the connection
Other tcl client is trying to asses the same connection.
i.e reason I want different connection objects
- 09-21-2009, 11:21 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
But those errors are most likely coming from errors elsewhere. You should have posted the errors you were getting.
Check the logic of your code. Perhaps you are trying to read data from closed connections.
- 09-21-2009, 11:47 AM #5
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
When multiple users access web service or any module related to database, same connection is served for all requests and errors like "Exhauseted Resultset " are thrown. Datasource is configured in server.xml of tomcat and connection is fetched through datasource. Web server used is Tomcat 5.5 and database is Oracle 9i.
I have given the steps used by one of the modules called Query Service. This gives the problem described above.
The TCL client sends query in a pre-defined format to the web service. It uses SOAP messages.
The web service which is based on Axis2, will parse the query, submit the query to the database server through application server (Tomcat).
The application server query data from Oracle database.
The web service process result and send response back to the client in a pre-defined format.
The TCL client will then parse the formatted result and return the response to the user.
When multiple users try to access Query Service, we are facing problem. This module works fine for single user.
- 09-21-2009, 11:54 AM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
The problem probably lies in how you have your classes set up. You should be using connection pooling so users don't have to share the one connection. You also need to make sure that you acquire a connection, use it, and close it soon after every time. Don't make connections instance variables because multiple threads accessing them could mess them up.
- 03-24-2011, 11:15 AM #7
Member
- Join Date
- Oct 2009
- Posts
- 8
- Rep Power
- 0
Hi All,
I am new to java.
I want to get the data from 3 table.
first i will use a query on both table . after getting the result set. i want to write on more query inside the result set with where clause .
so that i will get only corresponding match records from third table in the result set.
please let me know how to write the code.
my code is as below:
try{
String sql = "select DISTINCT REQUISITIONS.FOLDERID, REQUISITIONS.AUTOREQ, REQUISITIONS.MANAGERID, REQUISITIONS.RECRUITERID, " +
" REQUISITIONRESPONSE.FOLDERID, REQUISITIONRESPONSE.QUESTION_TYPE_ID, REQUISITIONRESPONSE.RESPONSE " +
" from REQUISITIONS,REQUISITIONRESPONSE" +
" where REQUISITIONS.FOLDERID=REQUISITIONRESPONSE.FOLDERID ";
System.out.println(":kishan test data1 " );
ResultSet rs1 = st.executeQuery(sql);
while(rs1.next())
{
System.out.println(":kishan test data2 " );
int aInt = Integer.parseInt(rs1.getString(1));
Candidate candidate=new Candidate();
candidate.setRsKey(+aInt);
candidate.setEmail(rs1.getString(2));
candidate.setName(rs1.getString(3));
candidate.setPhone(rs1.getString(4));
candidate.setDegree(rs1.getString(5));
candidate.setGradyear(rs1.getString(6));
candidate.setSchoolname(rs1.getString(7));
String sql1 = "select QUESTION_TYPE_ID, QUESTION_DESC from QUESTION_TYPE where QUESTION_TYPE_ID='"+rs1.getString(6)+"'";
ResultSet rs2 = st.executeQuery(sql1);
while(rs2.next())
{
System.out.println(":kishan test data in second query " +rs2.getString(1));
if (rs2.getString(2).equals("Cost Center")){
candidate.setJobtitle(rs1.getString(7));
}else if (rs2.getString(2).equals("Business Unit")){
candidate.setOrgname(rs1.getString(7));
}
}
candidate.setJobtitle(rs1.getString(8));
candidate.setOrgname(rs1.getString(9));
list.add(candidate);
}
}
Here i am getting Exhuasted Result set exception.
- 03-24-2011, 11:37 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Similar Threads
-
DriverManager vs. DataSource
By drieskn in forum JDBCReplies: 4Last Post: 02-05-2009, 04:38 AM -
JasperReports dataSource.
By hendrix79 in forum Advanced JavaReplies: 0Last Post: 01-29-2009, 10:54 AM -
Datasource & JNDI error
By shweta in forum New To JavaReplies: 4Last Post: 05-15-2008, 08:43 AM -
Cannot set DataSource for RowSet
By piterskiy in forum JDBCReplies: 0Last Post: 12-07-2007, 07:58 PM -
Datasource
By samson in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 04-02-2007, 11:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks