File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes multiple processes... only want one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "multiple processes... only want one" Watch "multiple processes... only want one" New topic
Author

multiple processes... only want one

Charlotte Shearrill
Ranch Hand

Joined: Dec 07, 2001
Posts: 34
i have a loop that connects to my SQL server database. for each outside loop a process is created. this is not what i want. i want one process to house all of the queries creating only one process. what am i doing wrong? what should be the first thing that i should check in trying to solve this issue? here is a sample of my code that i am using to reek havoc:
*******************
private void createListing (DefaultMutableTreeNode theBigGuy) {
DefaultMutableTreeNode owner = null;
DefaultMutableTreeNode employee = null;
//********************************************
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbcSTUFF ";
String user = "theUser";
String password = "theUserPass";
Connection con = DriverManager.getConnection(url, theUser, theUserPass);
String miNumber = getParameter("myNum");
String SQLstmt = "SELECT * FROM table1 WHERE log='" + myNum + "')";
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//********************************************
try{

ResultSet rs = stmt.executeQuery(SQLstmt);
while(rs.next()){
int User_ID = rs.getInt("userID");

String SQLstmt1 = "SELECT * FROM table2 WHERE userID =" + User_ID;
Statement stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//********************************************
try{
ResultSet rs1 = stmt1.executeQuery(SQLstmt1);
while (rs1.next()) {

int user2_ID = rs1.getInt("user2ID");
String user_Name = rs1.getString("uName");

owner = new DefaultMutableTreeNode(user_Name);
top.add(owner);

String SQLstmt2 = "SELECT * FROM table3 WHERE uID =" + user2_ID ";
Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//********************************************
try{
ResultSet rs2 = stmt2.executeQuery(SQLstmt2);
while (rs2.next()){
int other_ID = rs2.getInt("otherID");
String other_Name = rs2.getString("otherName");
int other_Cnt = rs2.getInt("otherCnt");
String SQLstmt3 = "select * from table4 where level <> '0'";
Statement stmt3 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//********************************************
try{

ResultSet rs3 = stmt3.executeQuery(SQLstmt3);
while (rs3.next()){
DO SOME BIG STUFF WITH OTHER CODE
}
}
rs3.close();
}
catch(Exception ea){
System.out.println("Problem with execution of RS3 query");
ea.printStackTrace();
return;
}
}
rs2.close();
}

catch(Exception eb){
System.out.println("Problem with execution of RS2 query");
eb.printStackTrace();
return;
}
}
rs1.close();
}
catch(Exception ec){
System.out.println("Problem with execution of RS1 query");
ec.printStackTrace();
return;
}

}
rs.close();
}

catch(Exception ed){
System.out.println("Problem with trying to execute query in table1");
ed.printStackTrace();
return;
}
con.close();
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple processes... only want one
 
Similar Threads
RMI Exception! Please give me a hand!
nested resultsets
stored procedures in a loop... what gives?
dropdown filter
Retrive 4000 more records