RE: Speed issues with SQL Server 2000 and JTDS
I tried pinging the server and responses are all 1ms. I have also tried without a DB Connection, Fast, with a DB Connection and no query, slow, and with a DB Connection and with a query, just as slow. Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 2:25 PM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS Try pinging the server with Microsoft SQL Server from the server running tomcat. You might use a traceroute to see where the network bottleneck may exist. What are your ping times. Are you experiencing network latency? Are you going through a Firewall? I am using JTDS and I have not experienced any problems with it. Randall -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:57 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I tried setting that parameter to false and still the same slow issue. The fields in the database are all char or varchar. No unicode. Charles -Original Message- From: Victor Cardona [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:44 AM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import
Re: Speed issues with SQL Server 2000 and JTDS
Since the addition of the query does not add to the time then using a connection pool will return your speed to normal. You may wish to dive into the connection issue and determine what is causing it to be so slow to connect. IE put a sniffer on the line and see what is going back and forth. It could also be in the drivers or a number of other issues. There may be some parameters on the connection that will give you a faster connect time. At this point I think you are down to two choices: 1. Use pooling to eliminate the connection lag time(that's what it was developed for in the first place). 2. Try different drivers and/or parameters to speed up the connect time. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Friday, January 07, 2005 2:43 PM Subject: RE: Speed issues with SQL Server 2000 and JTDS I tried pinging the server and responses are all 1ms. I have also tried without a DB Connection, Fast, with a DB Connection and no query, slow, and with a DB Connection and with a query, just as slow. Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 2:25 PM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS Try pinging the server with Microsoft SQL Server from the server running tomcat. You might use a traceroute to see where the network bottleneck may exist. What are your ping times. Are you experiencing network latency? Are you going through a Firewall? I am using JTDS and I have not experienced any problems with it. Randall -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:57 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I tried setting that parameter to false and still the same slow issue. The fields in the database are all char or varchar. No unicode. Charles -Original Message- From: Victor Cardona [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:44 AM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like
RE: Speed issues with SQL Server 2000 and JTDS
Hi, I am using SQL server as well and is very very fast. How? We use a connection pooling jar (commercial, not that much) called JSQLConnect. How I implement this? I create an class Connectionpool where I make the connection etc. In each class I do this: static private ConnectionPool poolinstance = ConnectionPool.getPoolInstance(); This works great and the connection delay to the DB is no issue anymore. Maarten -Oorspronkelijk bericht- Van: Charles P. Killmer [mailto:[EMAIL PROTECTED] Verzonden: Wednesday, January 05, 2005 7:57 PM Aan: Tomcat Users List Onderwerp: RE: Speed issues with SQL Server 2000 and JTDS I tried setting that parameter to false and still the same slow issue. The fields in the database are all char or varchar. No unicode. Charles -Original Message- From: Victor Cardona [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:44 AM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod
RE: Speed issues with SQL Server 2000 and JTDS
Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close
Re: Speed issues with SQL Server 2000 and JTDS
Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close
RE: Speed issues with SQL Server 2000 and JTDS
I tried setting that parameter to false and still the same slow issue. The fields in the database are all char or varchar. No unicode. Charles -Original Message- From: Victor Cardona [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:44 AM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt
RE: Speed issues with SQL Server 2000 and JTDS
Try pinging the server with Microsoft SQL Server from the server running tomcat. You might use a traceroute to see where the network bottleneck may exist. What are your ping times. Are you experiencing network latency? Are you going through a Firewall? I am using JTDS and I have not experienced any problems with it. Randall -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:57 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I tried setting that parameter to false and still the same slow issue. The fields in the database are all char or varchar. No unicode. Charles -Original Message- From: Victor Cardona [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 05, 2005 11:44 AM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt
Re: Speed issues with SQL Server 2000 and JTDS
Charles P. Killmer wrote: Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null
Re: Speed issues with SQL Server 2000 and JTDS
It appears that you are dealing with a connection issue to the database server. Since you are not running any queries, the data is not an issue. There may still be other issues that are slowing things down. Once the connection is established, is the connection response normal. That is why I ask about item 3 and 4. If the time gets even worse then you have other issues that will need addressing. If two and three are about the same response time then concentrate on one of two thing. Find out what is making the establishment of the connection so slow or set up a connection pool (the one with Tomcat works fine) thus eliminating the connection time. If it increases, look at the network for issues. As suggested try some pings and traceroutes to see the times and possible causes. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Wednesday, January 05, 2005 8:58 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Thanks. I had already done this but maybe not communicated them as concisely. Thanks Charles -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 6:23 PM To: Tomcat Users List Subject: Re: Speed issues with SQL Server 2000 and JTDS Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. (Done runs slow) 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null
Re: Speed issues with SQL Server 2000 and JTDS
Hey Charles, I have implement a database driver that I found online do you think it will help you out??? Charles P. Killmer wrote: I bought the Core Servlets and Java Server Pages and read it over the weekend. Happy New Year to me. I did get out to a few parties though. ;) I am having trouble getting JTDS to return results quickly. Has anyone got any example code for how to properly query a SQL Server 2000 database? The code I write needs to work with both SQL Server 2000 and SQL Server 7. In creating the connection, I am specifying TYPE_SCROLL_INSENSITIVE and TYPE_CONCUR_READ_ONLY. I tried not specifying anything and got errors about not being able to scroll the results. Is the only solution to this, use FORWARD_ONLY and buffer the contents myself? I hoping there is a better way. Thank you Charles Killmer -- Dwayne A. Ghant Application Developer Temple University 215.204. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Speed issues with SQL Server 2000 and JTDS
Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close(); } } }catch(Exception E){ logger.error(EXCEPTION ERROR Getting Applicant: + E.toString()); } finally{ // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt != null){ stmt.close(); stmt=null; } }catch(SQLException E){} try{ if(rst != null) { rst.close(); rst = null
RE: Speed issues with SQL Server 2000 and JTDS
A couple of things to try to narrow things down. 1. creating an ODBC connection using asp or vbscript. Plenty of examples on the web. 2. Load the driver in a static block or somewhere else independent of where the connection is created. Drivers only need to be loaded once, so see if the performance improves if you don't repeatedly load it. 3. Try connection pooling. [EMAIL PROTECTED] 01/04 10:23 am Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try {
Re: Speed issues with SQL Server 2000 and JTDS
Trying a few test should help you narrow things down a bit. 1. Run without DB connection. (Done runs fast) 2. Run with a DB connect but no query. 3. Run with a simple query and do nothing with it. 4. Run with a simple query and post results in page. Only move forward through result set. 5. Run with a simple query and post results in page. Move around in the result set (Only if you do this in your page). At some point in these test you should see a dramatic jump in the response time. If it is a steady climb, then you may have multiple issues. Report back what you find and we'll make suggestions from there. Doug - Original Message - From: Charles P. Killmer [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, January 04, 2005 11:23 AM Subject: RE: Speed issues with SQL Server 2000 and JTDS Could this speed issue be caused by a poor setup? When I remove the database connection from my code, the pages run fast. Though I obviously need the database portion of the code in there. Thanks Charles -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 9:05 AM To: tomcat-user@jakarta.apache.org; Charles P. Killmer Subject: RE: Speed issues with SQL Server 2000 and JTDS You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close(); } } }catch(Exception E){ logger.error(EXCEPTION ERROR Getting Applicant: + E.toString()); } finally{ // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt != null
RE: Speed issues with SQL Server 2000 and JTDS
I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ /** * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close(); } } }catch(Exception E){ logger.error(EXCEPTION ERROR Getting Applicant: + E.toString()); } finally{ // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt != null){ stmt.close(); stmt=null; } }catch(SQLException E){} try{ if(rst != null) { rst.close(); rst = null; } }catch(SQLException E){} try{ if(conn != null) { conn.close(); conn = null; } }catch(SQLException E){} } } } This is the quirky part about Tomcat, in version 5.0 or ealier, I have to use this xml code in my webapp context file for DBCP. Resource name=jdbc/summitexec auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/summitexec parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameurl/name valuejdbc:jtds:sqlserver://192.168.0.2:1433/summitexec;User=someuser;P assword=somepassword/value /parameter parameter namedriverClassName/name valuenet.sourceforge.jtds.jdbc.Driver/value /parameter parameter nameuser/name valuesomeuser/value /parameter parameter namepassword/name valuesomepassword/value /parameter /ResourceParams In 5.5 I have to use this xml for DBCP. If someone could provide details why this is, I would appreciate it. Resource name=jdbc/summitexec auth=Container type=javax.sql.DataSource driverClassName=net.sourceforge.jtds.jdbc.Driver url=jdbc:jtds:sqlserver://192.168.0.3:1433/summitexec username=someuser password=somepassword maxActive=20 maxIdle=10 maxWait=10/ Thanks, Randall -Original Message- From: Charles P. Killmer [mailto:[EMAIL PROTECTED] Sent: Sunday, January 02, 2005 2:13 PM To: Tomcat Users List Subject: Speed issues with SQL Server 2000 and JTDS I bought the Core Servlets and Java Server Pages and read it over the weekend. Happy New Year to me. I did get out to a
RE: Speed issues with SQL Server 2000 and JTDS
This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ /** * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close(); } } }catch(Exception E){ logger.error(EXCEPTION ERROR Getting Applicant: + E.toString()); } finally{ // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt != null){ stmt.close(); stmt=null; } }catch(SQLException E){} try{ if(rst != null) { rst.close(); rst = null; } }catch(SQLException E){} try{ if(conn != null) { conn.close(); conn = null; } }catch(SQLException E){} } } } This is the quirky part about Tomcat, in version 5.0 or ealier, I have to use this xml code in my webapp context file for DBCP. Resource name=jdbc/summitexec auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/summitexec parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameurl/name valuejdbc:jtds:sqlserver://192.168.0.2:1433/summitexec;User=someuser;P assword=somepassword/value /parameter parameter
RE: Speed issues with SQL Server 2000 and JTDS
You could try using something like jProfiler to see where the bottleneck is. I don't see anything unusual in your code example, although it looks like the only thing it does is create the connection. I use jTDS and it works fine without doing anything exceptional. [EMAIL PROTECTED] 01/03 8:55 am This is some representative code that is being very slow. import java.sql.*; public class SomeClass { public Connection conn; public int ID; public String Name; public String Address; public String City; public String OtherStuff; public SomeClass() throws Exception { try { Class.forName(net.sourceforge.jtds.jdbc.Driver); } catch (ClassNotFoundException ex) { } try { conn = DriverManager.getConnection(jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=someuser;password=somepassword); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs = null; return rs; } public int DeleteSomething() throws Exception { return 2; } } I don't have anything special in any XML files. I will try to make my code work like yours is. But if someone has an idea why the way I have it written is slow, I would love to hear it. Thank You Charles -Original Message- From: Randall Svancara [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 8:20 AM To: Tomcat Users List Subject: RE: Speed issues with SQL Server 2000 and JTDS I have been using JTDS with SQL Server 2000 in conjunction with Tomcat without any problems. Perhaps if you post some your database connection code, someone could provide you with assistance. You might also try posting to the JTDS Mailing list. Are you using Database Connection Pooling (DBCP)?? I am including an example the code I use to access a stored procedure on SQL Server 2000 using DBCP. /* Here are the things I import */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import javax.naming.*; import javax.sql.*; Public class SomeClass{ * A public class that returns an Applicant object * @return the applicant as applicant */ public Applicant SomeApplicantMethod(){ Applicant app = new Applicant(); Connection conn = null; Statement stmt = null; ResultSet rst = null; try{ Context ctx = new InitialContext(); /* Declare initial context */ if(ctx == null ){ logger.error(Error creating new context for some reason); throw new Exception(No context); } /* Throw an exception if it is null */ DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/summitexec); conn = ds.getConnection(); if(conn != null) { stmt = conn.createStatement(); rst = stmt.executeQuery(sp_SelectApplicant + canidateid); while(rst.next()){ // Add result set to applicant object, NOT SHOWN HERE!!! } //Make sure you close everything, else you end up with object leaks if(stmt != null){ stmt.close(); } if(rst != null){ rst.close(); } if(conn != null){ conn.close(); } } }catch(Exception E){ logger.error(EXCEPTION ERROR Getting Applicant: + E.toString()); } finally{ // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt != null){ stmt.close(); stmt=null; } }catch(SQLException E){} try{ if(rst != null) { rst.close(); rst = null; } }catch(SQLException E){} try{ if(conn != null) { conn.close(); conn = null; } }catch(SQLException E){} } } } This is the quirky part about Tomcat, in version 5.0 or ealier, I have to use this xml code in my webapp context file for DBCP. Resource name