Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 79993 invoked from network); 3 Jan 2005 14:56:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 3 Jan 2005 14:56:29 -0000 Received: (qmail 32079 invoked by uid 500); 3 Jan 2005 14:55:39 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 32001 invoked by uid 500); 3 Jan 2005 14:55:36 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 31982 invoked by uid 99); 3 Jan 2005 14:55:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail01.netgaintechnology.com (HELO mail01.netgaintechnology.com) (209.188.110.20) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 03 Jan 2005 06:55:10 -0800 Received: from hosting.netgaintechnology.com [64.83.222.156] by mail01.netgaintechnology.com with ESMTP (SMTPD32-8.13) id AD9388DC00E6; Mon, 03 Jan 2005 08:58:27 -0600 Received: from ngsv24.my-netgain.com ([10.0.1.14]) by hosting.netgaintechnology.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 3 Jan 2005 08:55:01 -0600 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Subject: RE: Speed issues with SQL Server 2000 and JTDS Date: Mon, 3 Jan 2005 08:55:01 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Speed issues with SQL Server 2000 and JTDS Thread-Index: AcTxD+BVbiuAHzfJSHiKLnqALuGrOAAjYzawAAFn2YA= From: "Charles P. Killmer" To: "Tomcat Users List" X-OriginalArrivalTime: 03 Jan 2005 14:55:01.0480 (UTC) FILETIME=[33898E80:01C4F1A4] X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is some representative code that is being very slow. =20 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 =3D DriverManager.getConnection("jdbc:jtds:sqlserver://111.222.333.444:1433/ someDB;user=3Dsomeuser;password=3Dsomepassword"); } catch (Exception e) { throw e; } } public int Audit() throws Exception { return 5; } public ResultSet GetData() throws Exception { ResultSet rs =3D 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=20 -----Original Message----- From: Randall Svancara [mailto:rsvancara@adaweb.net]=20 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. =20 /* 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 =3D new Applicant(); Connection conn =3D null; Statement stmt =3D null; ResultSet rst =3D null; =20 try{ Context ctx =3D new InitialContext(); /* Declare initial context */ if(ctx =3D=3D null ){ logger.error("Error creating new context for some reason"); throw new Exception("No context"); } /* Throw an exception if it is null */ DataSource ds =3D (DataSource)ctx.lookup("java:comp/env/jdbc/summitexec"); =20 conn =3D ds.getConnection(); =20 if(conn !=3D null) { =20 stmt =3D conn.createStatement(); =20 rst =3D stmt.executeQuery("sp_SelectApplicant " + canidateid); =20 while(rst.next()){ =09 // Add result set to applicant object, NOT SHOWN HERE!!! } =20 //Make sure you close everything, else you end up with object leaks.... if(stmt !=3D null){ stmt.close(); } =20 if(rst !=3D null){ rst.close(); } =20 if(conn !=3D null){ conn.close(); } } }catch(Exception E){ logger.error("EXCEPTION ERROR Getting Applicant: " + E.toString()); } finally{ =20 // Close out of any open connections if they exist, this is important // in order to release resources for connection pooling try{ if(stmt !=3D null){ stmt.close(); stmt=3Dnull; } }catch(SQLException E){} =20 try{ if(rst !=3D null) { rst.close(); rst =3D null; } }catch(SQLException E){} =20 try{ if(conn !=3D null) { conn.close(); conn =3D null; } }catch(SQLException E){} } =09 } } 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. factory =20 org.apache.commons.dbcp.BasicDataSourceFactory url =09 jdbc:jtds:sqlserver://192.168.0.2:1433/summitexec;User=3Dsomeuser;= P assword=3Dsomepassword driverClassName net.sourceforge.jtds.jdbc.Driver =20 user someuser password somepassword In 5.5 I have to use this xml for DBCP. If someone could provide details why this is, I would appreciate it. =20 Thanks, Randall -----Original Message----- From: Charles P. Killmer [mailto:charlesk@netgaintechnology.com] 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 few parties though. ;) I am having trouble getting JTDS to return results quickly.=20 =20 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. =20 Thank you Charles Killmer =20 --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org