RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
I tried the management console way because I was not sure I was getting the xml 
right.  I will stick with that until I find something wrong with the generated 
xml.

-Original Message-
From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
Sent: Friday, April 13, 2007 11:09 AM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
> I am putting my Resource inside the GlobalNamingResource.  Do I need anything 
> in the Context node?
>

If you are using GlobalNamingResource you don't need the Context node
because it is global to all contexts and not just one context.

> I have been doing this two different ways.  My latest attempts I have used 
> the management > console which generates the server.xml file.

Focus on one way :-) and get it to work before attempting alternatives.

>

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-13 Thread Rashmi Rubdi

On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:

I am putting my Resource inside the GlobalNamingResource.  Do I need anything 
in the Context node?



If you are using GlobalNamingResource you don't need the Context node
because it is global to all contexts and not just one context.


I have been doing this two different ways.  My latest attempts I have used the 
management > console which generates the server.xml file.


Focus on one way :-) and get it to work before attempting alternatives.





-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
I am putting my Resource inside the GlobalNamingResource.  Do I need anything 
in the Context node?

I have been doing this two different ways.  My latest attempts I have used the 
management console which generates the server.xml file.

-Original Message-
From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
Sent: Friday, April 13, 2007 10:27 AM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


As Len Popp mentioned before, the syntax for Connection Pooling is
different for certain versions of Tomcat.

If you carefully follow the documentation of "JDBC DataSources" for
*your* version of Tomcat http://tomcat.apache.org/ , and do some
additional minor research on the pseudo-code presented in the  How-To
document, you should be able to connect with Connection Pooling.

One common mistake I've seen is people forget to nest the Context node
inside the Host node, or forget to associate an external Context file
to a particular Host in server.xml

If you think anything is misconfigured or too confusing, it helps to
start with a fresh install of the version of Tomcat you intend to use.

-Rashmi

On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
> Your right.  My ResourceParam syntax is different.  I didn't look closely at 
> that.  My values are mostly the same.
>

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-13 Thread Rashmi Rubdi

As Len Popp mentioned before, the syntax for Connection Pooling is
different for certain versions of Tomcat.

If you carefully follow the documentation of "JDBC DataSources" for
*your* version of Tomcat http://tomcat.apache.org/ , and do some
additional minor research on the pseudo-code presented in the  How-To
document, you should be able to connect with Connection Pooling.

One common mistake I've seen is people forget to nest the Context node
inside the Host node, or forget to associate an external Context file
to a particular Host in server.xml

If you think anything is misconfigured or too confusing, it helps to
start with a fresh install of the version of Tomcat you intend to use.

-Rashmi

On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:

Your right.  My ResourceParam syntax is different.  I didn't look closely at 
that.  My values are mostly the same.



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
Your right.  My ResourceParam syntax is different.  I didn't look closely at 
that.  My values are mostly the same.

-Original Message-
From: Len Popp [mailto:[EMAIL PROTECTED]
Sent: Friday, April 13, 2007 9:25 AM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


It should *not* look the same, because the syntax of the 
element changed after 5.0. Look for  in the 5.0
documentation.
-- 
Len

On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
> Thanks.  I am using 5.0.28, but what I have looks like what you have.  I will 
> take a closer look to make sure I didn't miss something.
>
> -Original Message-
> From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 12, 2007 5:59 PM
> To: Tomcat Users List
> Subject: Re: DB2 DataSource.
>
>
> Your Tomcat version is not known, so I'm assuming the latest version 6.0.10.
>
> Here's what should go in:
> --
> ./MyProject/WEB-INF/web.xml
> --
> 
> http://java.sun.com/xml/ns/javaee";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
> web-app_2_5.xsd"
>  version="2.5">
>   MySQL Test App
>   
>   DB Connection
>   jdbc/TestDB
>   javax.sql.DataSource
>   Container
>   
> 
>
> -
> According to the HOW-TO document I gave earlier the JAR for the JDBC
> driver must be placed in Tomcat's lib folder, so
> ...\apache-tomcat-6.0.10_bak_20070410\lib\
> -
> mysql-connector-java-5.0.5-bin.jar
>
> -
> Add the connection pooling configuration to your application's Context
> definition
> -
>  reloadable="true" debug="true">
>  type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="1"
> username="javauser" password="javadude"
> driverClassName="com.mysql.jdbc.Driver"
> 
> url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
> 
>
>
> -
> And finally, here's the sample working code:
> /WEB-INF/classes/com/connectionpooltest/ConnectionPoolTest.java
> 
> package com.connectionpooltest;
>
> import java.sql.*;
> import javax.naming.*;
> import javax.sql.DataSource;
>
> public class ConnectionPoolTest {
>
> public void testConnection() throws SQLException, NamingException{
> Connection conn = null;
> Statement stmt = null;
> ResultSet rs = null;
>
> try{
> //conn = ... get connection from connection pool ...
> Context initContext = new InitialContext();
> Context envContext  = 
> (Context)initContext.lookup("java:/comp/env");
> DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");
> conn = ds.getConnection();
>
> //stmt = conn.createStatement("select ...");
> stmt = conn.createStatement();
>
> //rs = stmt.executeQuery();
> rs = stmt.executeQuery("SELECT 'Java Connection Pooling Test' as
> a FROM dual");
>
> //... iterate through the result set ...
> while (rs.next()) {
> String s = rs.getString("a");
> System.out.println(" s is : " + s);
> }
>
> rs.close();
> rs = null;
> stmt.close();
> stmt = null;
> conn.close(); // Return to connection pool
> conn = null;  // Make sure we don't close it twice
>
> }catch(SQLException e){
> e.printStackTrace();
> }finally{
> // Always make sure result sets and statements are closed,
> // and the connection is returned to the pool
> if (rs != null) {
>   try { rs.close(); } catch (SQLException e) { 
> e.printStackTra

Re: DB2 DataSource.

2007-04-13 Thread Len Popp

It should *not* look the same, because the syntax of the 
element changed after 5.0. Look for  in the 5.0
documentation.
--
Len

On 4/13/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:

Thanks.  I am using 5.0.28, but what I have looks like what you have.  I will 
take a closer look to make sure I didn't miss something.

-Original Message-
From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 5:59 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


Your Tomcat version is not known, so I'm assuming the latest version 6.0.10.

Here's what should go in:
--
./MyProject/WEB-INF/web.xml
--

http://java.sun.com/xml/ns/javaee";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd"
 version="2.5">
  MySQL Test App
  
  DB Connection
  jdbc/TestDB
  javax.sql.DataSource
  Container
  


-
According to the HOW-TO document I gave earlier the JAR for the JDBC
driver must be placed in Tomcat's lib folder, so
...\apache-tomcat-6.0.10_bak_20070410\lib\
-
mysql-connector-java-5.0.5-bin.jar

-
Add the connection pooling configuration to your application's Context
definition
-





-
And finally, here's the sample working code:
/WEB-INF/classes/com/connectionpooltest/ConnectionPoolTest.java

package com.connectionpooltest;

import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

public class ConnectionPoolTest {

public void testConnection() throws SQLException, NamingException{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try{
//conn = ... get connection from connection pool ...
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");
conn = ds.getConnection();

//stmt = conn.createStatement("select ...");
stmt = conn.createStatement();

//rs = stmt.executeQuery();
rs = stmt.executeQuery("SELECT 'Java Connection Pooling Test' as
a FROM dual");

//... iterate through the result set ...
while (rs.next()) {
String s = rs.getString("a");
System.out.println(" s is : " + s);
}

rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close(); // Return to connection pool
conn = null;  // Make sure we don't close it twice

}catch(SQLException e){
e.printStackTrace();
}finally{
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rs != null) {
  try { rs.close(); } catch (SQLException e) { e.printStackTrace(); 
}
  rs = null;
}
if (stmt != null) {
  try { stmt.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  stmt = null;
}
if (conn != null) {
  try { conn.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  conn = null;
}
}
}

}

Since Connection Pooling is handled by the Container, the above code
must be called from within the context of the Container --- so it must
be called from either a Servlet or a JSP page --- it cannot be called
from the command line alone using a main method.

-Rashmi

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
Thanks.  I am using 5.0.28, but what I have looks like what you have.  I will 
take a closer look to make sure I didn't miss something.

-Original Message-
From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 5:59 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


Your Tomcat version is not known, so I'm assuming the latest version 6.0.10.

Here's what should go in:
--
./MyProject/WEB-INF/web.xml
--

http://java.sun.com/xml/ns/javaee";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd"
 version="2.5">
  MySQL Test App
  
  DB Connection
  jdbc/TestDB
  javax.sql.DataSource
  Container
  


-
According to the HOW-TO document I gave earlier the JAR for the JDBC
driver must be placed in Tomcat's lib folder, so
...\apache-tomcat-6.0.10_bak_20070410\lib\
-
mysql-connector-java-5.0.5-bin.jar

-
Add the connection pooling configuration to your application's Context
definition
-

 



-
And finally, here's the sample working code:
/WEB-INF/classes/com/connectionpooltest/ConnectionPoolTest.java

package com.connectionpooltest;

import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

public class ConnectionPoolTest {

public void testConnection() throws SQLException, NamingException{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try{
//conn = ... get connection from connection pool ...
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");
conn = ds.getConnection();

//stmt = conn.createStatement("select ...");
stmt = conn.createStatement();

//rs = stmt.executeQuery();
rs = stmt.executeQuery("SELECT 'Java Connection Pooling Test' as
a FROM dual");

//... iterate through the result set ...
while (rs.next()) {
String s = rs.getString("a");
System.out.println(" s is : " + s);
}

rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close(); // Return to connection pool
conn = null;  // Make sure we don't close it twice

}catch(SQLException e){
e.printStackTrace();
}finally{
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rs != null) {
  try { rs.close(); } catch (SQLException e) { e.printStackTrace(); 
}
  rs = null;
}
if (stmt != null) {
  try { stmt.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  stmt = null;
}
if (conn != null) {
  try { conn.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  conn = null;
}   
}
}

}

Since Connection Pooling is handled by the Container, the above code
must be called from within the context of the Container --- so it must
be called from either a Servlet or a JSP page --- it cannot be called
from the command line alone using a main method.

-Rashmi

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
I think I have all the jar files in the right place.  In fact I can access DB2 
when I use DriverManager.

-Original Message-
From: Foo Shyn [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 11:14 PM
To: Tomcat Users List
Cc: Martin Gainty
Subject: Re: DB2 DataSource.


Hi,

I'd been using connection pooling setting in Tomcat for MySQL, MSSQL and 
Derby(or Cloudscape) so i guess DB2 could be setup just as same.

Make sure your driver jar file includes the Driver which is packaged as you 
had declared in the XML. And place it in the Tomcat common lib folder (In 
Tomcat 4.1's case, Tomcat 4.1\common\lib).

Thanx.
Regards,
FooShyn
- Original Message - 
From: "Pulkit Singhal" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Cc: "Martin Gainty" <[EMAIL PROTECTED]>
Sent: Friday, April 13, 2007 1:05 PM
Subject: Re: DB2 DataSource.


> The following is copy/pasted from
> http://jtds.sourceforge.net/faq.html#noSuitableDriver
>
> Why do I get a java.sql.SQLException: "No suitable driver" when trying to
> get a connection?
>
> The "No suitable driver" exception is thrown by the DriverManager when 
> none
> of the registered Driver implementations recognizes the supplied URL. This
> means that you either did not register jTDS with the DriverManager first 
> (by
> calling Class.forName("net.sourceforge.jtds.jdbc.Driver")) or you mistyped
> the URL (e.g. "jbdc:jtds:..." instead of "jdbc:jtds:...").
>
> A common mistake is to append a semicolon (";") to the end of the URL 
> (e.g.
> "jdbc:jtds:sqlserver://server/db;TDS=7.0;" is wrong!).
>
> For more information about URL format and the properties that may be 
> passed
> to jTDS have a look at the jTDS URL
> format<http://jtds.sourceforge.net/faq.html#urlFormat>
> .
>
>
> On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
>>
>> Thanks.  Unfortunately I did try this example before.  It doesn't work. 
>> I
>> get an exception, and along with the stack dump I display I get "Caused 
>> by:
>> java.sql.SQLException: No suitable driver".
>>
>> I am hoping that someone has a working example that they actually tested.
>>
>> -Original Message-
>> From: Martin Gainty [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, April 12, 2007 3:19 PM
>> To: Tomcat Users List
>> Subject: Re: DB2 DataSource.
>>
>>
>> Alan-
>>
>> http://www.itjungle.com/fhg/fhg051204-story01.html
>>
>> Viel Gluck/Buena Suerte
>>
>> Martin--
>> This email message and any files transmitted with it contain confidential
>> information intended only for the person(s) to whom this email message is
>> addressed.  If you have received this email message in error, please
>> notify
>> the sender immediately by telephone or email and destroy the original
>> message without making a copy.  Thank you.
>>
>> - Original Message -
>> From: "Fargusson.Alan" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Thursday, April 12, 2007 6:01 PM
>> Subject: DB2 DataSource.
>>
>>
>> Can someone point me to documentation on setting up a DataSource to DB2?
>>
>> I tried to use the examples for Oracle and MySql, but I have not been 
>> able
>> to get it to work.
>>
>> I am able to access DB2 using the DriverManager.
>>
>> -
>> To start a new topic, e-mail: [EMAIL PROTECTED]
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>> -
>> To start a new topic, e-mail: [EMAIL PROTECTED]
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> -
>> To start a new topic, e-mail: [EMAIL PROTECTED]
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>





No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.3.0/758 - Release Date: 4/12/2007 
11:52 AM



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-13 Thread Fargusson.Alan
Actually my program works when I use DriverManager.  It only failes when I use 
a DataSource.

-Original Message-
From: Pulkit Singhal [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 10:06 PM
To: Tomcat Users List
Cc: Martin Gainty
Subject: Re: DB2 DataSource.


The following is copy/pasted from
http://jtds.sourceforge.net/faq.html#noSuitableDriver

Why do I get a java.sql.SQLException: "No suitable driver" when trying to
get a connection?

The "No suitable driver" exception is thrown by the DriverManager when none
of the registered Driver implementations recognizes the supplied URL. This
means that you either did not register jTDS with the DriverManager first (by
calling Class.forName("net.sourceforge.jtds.jdbc.Driver")) or you mistyped
the URL (e.g. "jbdc:jtds:..." instead of "jdbc:jtds:...").

A common mistake is to append a semicolon (";") to the end of the URL (e.g.
"jdbc:jtds:sqlserver://server/db;TDS=7.0;" is wrong!).

For more information about URL format and the properties that may be passed
to jTDS have a look at the jTDS URL
format<http://jtds.sourceforge.net/faq.html#urlFormat>
.


On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
>
> Thanks.  Unfortunately I did try this example before.  It doesn't work.  I
> get an exception, and along with the stack dump I display I get "Caused by:
> java.sql.SQLException: No suitable driver".
>
> I am hoping that someone has a working example that they actually tested.
>
> -Original Message-
> From: Martin Gainty [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 12, 2007 3:19 PM
> To: Tomcat Users List
> Subject: Re: DB2 DataSource.
>
>
> Alan-
>
> http://www.itjungle.com/fhg/fhg051204-story01.html
>
> Viel Gluck/Buena Suerte
>
> Martin--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
>
> - Original Message -
> From: "Fargusson.Alan" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, April 12, 2007 6:01 PM
> Subject: DB2 DataSource.
>
>
> Can someone point me to documentation on setting up a DataSource to DB2?
>
> I tried to use the examples for Oracle and MySql, but I have not been able
> to get it to work.
>
> I am able to access DB2 using the DriverManager.
>
> -
> To start a new topic, e-mail: [EMAIL PROTECTED]
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> -
> To start a new topic, e-mail: [EMAIL PROTECTED]
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> -
> To start a new topic, e-mail: [EMAIL PROTECTED]
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-12 Thread Foo Shyn

Hi,

I'd been using connection pooling setting in Tomcat for MySQL, MSSQL and 
Derby(or Cloudscape) so i guess DB2 could be setup just as same.


Make sure your driver jar file includes the Driver which is packaged as you 
had declared in the XML. And place it in the Tomcat common lib folder (In 
Tomcat 4.1's case, Tomcat 4.1\common\lib).


Thanx.
Regards,
FooShyn
- Original Message - 
From: "Pulkit Singhal" <[EMAIL PROTECTED]>

To: "Tomcat Users List" <[EMAIL PROTECTED]>
Cc: "Martin Gainty" <[EMAIL PROTECTED]>
Sent: Friday, April 13, 2007 1:05 PM
Subject: Re: DB2 DataSource.



The following is copy/pasted from
http://jtds.sourceforge.net/faq.html#noSuitableDriver

Why do I get a java.sql.SQLException: "No suitable driver" when trying to
get a connection?

The "No suitable driver" exception is thrown by the DriverManager when 
none

of the registered Driver implementations recognizes the supplied URL. This
means that you either did not register jTDS with the DriverManager first 
(by

calling Class.forName("net.sourceforge.jtds.jdbc.Driver")) or you mistyped
the URL (e.g. "jbdc:jtds:..." instead of "jdbc:jtds:...").

A common mistake is to append a semicolon (";") to the end of the URL 
(e.g.

"jdbc:jtds:sqlserver://server/db;TDS=7.0;" is wrong!).

For more information about URL format and the properties that may be 
passed

to jTDS have a look at the jTDS URL
format<http://jtds.sourceforge.net/faq.html#urlFormat>
.


On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:


Thanks.  Unfortunately I did try this example before.  It doesn't work. 
I
get an exception, and along with the stack dump I display I get "Caused 
by:

java.sql.SQLException: No suitable driver".

I am hoping that someone has a working example that they actually tested.

-Original Message-
From: Martin Gainty [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 3:19 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


Alan-

http://www.itjungle.com/fhg/fhg051204-story01.html

Viel Gluck/Buena Suerte

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please
notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

- Original Message -
From: "Fargusson.Alan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 12, 2007 6:01 PM
Subject: DB2 DataSource.


Can someone point me to documentation on setting up a DataSource to DB2?

I tried to use the examples for Oracle and MySql, but I have not been 
able

to get it to work.

I am able to access DB2 using the DriverManager.

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]










No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.3.0/758 - Release Date: 4/12/2007 
11:52 AM




-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-12 Thread Pulkit Singhal

The following is copy/pasted from
http://jtds.sourceforge.net/faq.html#noSuitableDriver

Why do I get a java.sql.SQLException: "No suitable driver" when trying to
get a connection?

The "No suitable driver" exception is thrown by the DriverManager when none
of the registered Driver implementations recognizes the supplied URL. This
means that you either did not register jTDS with the DriverManager first (by
calling Class.forName("net.sourceforge.jtds.jdbc.Driver")) or you mistyped
the URL (e.g. "jbdc:jtds:..." instead of "jdbc:jtds:...").

A common mistake is to append a semicolon (";") to the end of the URL (e.g.
"jdbc:jtds:sqlserver://server/db;TDS=7.0;" is wrong!).

For more information about URL format and the properties that may be passed
to jTDS have a look at the jTDS URL
format<http://jtds.sourceforge.net/faq.html#urlFormat>
.


On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:


Thanks.  Unfortunately I did try this example before.  It doesn't work.  I
get an exception, and along with the stack dump I display I get "Caused by:
java.sql.SQLException: No suitable driver".

I am hoping that someone has a working example that they actually tested.

-Original Message-
From: Martin Gainty [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 3:19 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


Alan-

http://www.itjungle.com/fhg/fhg051204-story01.html

Viel Gluck/Buena Suerte

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please
notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

- Original Message -
From: "Fargusson.Alan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 12, 2007 6:01 PM
Subject: DB2 DataSource.


Can someone point me to documentation on setting up a DataSource to DB2?

I tried to use the examples for Oracle and MySql, but I have not been able
to get it to work.

I am able to access DB2 using the DriverManager.

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: DB2 DataSource.

2007-04-12 Thread Rashmi Rubdi

Your Tomcat version is not known, so I'm assuming the latest version 6.0.10.

Here's what should go in:
--
./MyProject/WEB-INF/web.xml
--

http://java.sun.com/xml/ns/javaee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd"
version="2.5">
 MySQL Test App
 
 DB Connection
 jdbc/TestDB
 javax.sql.DataSource
 Container
 


-
According to the HOW-TO document I gave earlier the JAR for the JDBC
driver must be placed in Tomcat's lib folder, so
...\apache-tomcat-6.0.10_bak_20070410\lib\
-
mysql-connector-java-5.0.5-bin.jar

-
Add the connection pooling configuration to your application's Context
definition
-





-
And finally, here's the sample working code:
/WEB-INF/classes/com/connectionpooltest/ConnectionPoolTest.java

package com.connectionpooltest;

import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

public class ConnectionPoolTest {

   public void testConnection() throws SQLException, NamingException{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try{
//conn = ... get connection from connection pool ...
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");
conn = ds.getConnection();

//stmt = conn.createStatement("select ...");
stmt = conn.createStatement();

//rs = stmt.executeQuery();
rs = stmt.executeQuery("SELECT 'Java Connection Pooling Test' as
a FROM dual");

//... iterate through the result set ...
while (rs.next()) {
String s = rs.getString("a");
System.out.println(" s is : " + s);
}

rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close(); // Return to connection pool
conn = null;  // Make sure we don't close it twice

}catch(SQLException e){
e.printStackTrace();
}finally{
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rs != null) {
  try { rs.close(); } catch (SQLException e) { e.printStackTrace(); 
}
  rs = null;
}
if (stmt != null) {
  try { stmt.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  stmt = null;
}
if (conn != null) {
  try { conn.close(); } catch (SQLException e) { 
e.printStackTrace(); }
  conn = null;
}   
}
   }

}

Since Connection Pooling is handled by the Container, the above code
must be called from within the context of the Container --- so it must
be called from either a Servlet or a JSP page --- it cannot be called
from the command line alone using a main method.

-Rashmi

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-12 Thread Fargusson.Alan
It might be helpful to look at your code.  I suspect that getting DB2 to work 
involves more then just replacing the MySql driver with a DB2 equivalent.

I have tried using the examples to get this to work.

-Original Message-
From: Rashmi Rubdi [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 4:56 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


I tried the example shown at the bottom of the page here:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
with MySQL and I got it to work, but I don't have DB2.

If you want the code with MySQL I can post it.

-Rashmi

On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:
> I am hoping that someone has a working example that they actually tested.

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-12 Thread Rashmi Rubdi

I tried the example shown at the bottom of the page here:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
with MySQL and I got it to work, but I don't have DB2.

If you want the code with MySQL I can post it.

-Rashmi

On 4/12/07, Fargusson.Alan <[EMAIL PROTECTED]> wrote:

I am hoping that someone has a working example that they actually tested.


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DB2 DataSource.

2007-04-12 Thread Fargusson.Alan
Thanks.  Unfortunately I did try this example before.  It doesn't work.  I get 
an exception, and along with the stack dump I display I get "Caused by: 
java.sql.SQLException: No suitable driver".

I am hoping that someone has a working example that they actually tested.

-Original Message-
From: Martin Gainty [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 3:19 PM
To: Tomcat Users List
Subject: Re: DB2 DataSource.


Alan-

http://www.itjungle.com/fhg/fhg051204-story01.html

Viel Gluck/Buena Suerte

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

- Original Message - 
From: "Fargusson.Alan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 12, 2007 6:01 PM
Subject: DB2 DataSource.


Can someone point me to documentation on setting up a DataSource to DB2?

I tried to use the examples for Oracle and MySql, but I have not been able 
to get it to work.

I am able to access DB2 using the DriverManager.

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DB2 DataSource.

2007-04-12 Thread Martin Gainty

Alan-

http://www.itjungle.com/fhg/fhg051204-story01.html

Viel Gluck/Buena Suerte

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

- Original Message - 
From: "Fargusson.Alan" <[EMAIL PROTECTED]>

To: <[EMAIL PROTECTED]>
Sent: Thursday, April 12, 2007 6:01 PM
Subject: DB2 DataSource.


Can someone point me to documentation on setting up a DataSource to DB2?

I tried to use the examples for Oracle and MySql, but I have not been able 
to get it to work.


I am able to access DB2 using the DriverManager.

-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]