Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

multiple processes... only want one

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
 
What's a year in metric? Do you know this metric stuff tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic