You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Frank von Daak <fr...@kpage.de> on 2003/08/30 11:51:25 UTC

Tomcat and MsSQL

Hi,

 
maybe, someone of you can help me... 
 
I try to port a webapplication from asp to java... 

First, I have used Websphere for this and everything worked ok, but then I 
decided to use tomcat4 (both under debian-linux)
 
My problem is the connection to a MSSQL-Database.
 
As JDBC-Driver I'm using the  "Microsoft SQL Server 2000 Driver for JDBC", 
which has an official linux-support. And I cn say, that it is working very 
well with websphere...
 
When I use the same jsp-files under tomcat, I get the following error, when 
trying to connect the sql-server:

[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
 
 
I have copied the 3 files "msbase.jar", "mssqlserver.jar" and "msutil.jar" to 
$CATALINA_HOME/common/lib and it seems, that tomcat can find them (as the 
error message says)
 
Here is the code, that I use to connect to the database:
 
--------------------------------------------------
 
<%@ page language="java" import="javax.sql.DataSource,java.sql.*"%>
<%
 
Connection db_con;
Statement db;
 
try {
  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
} catch (ClassNotFoundException e) {
  out.println("<h1>Der Datenbanktreiber konnte nicht gefunden werden:" + e + 
e.getMessage() + "</h1>" );
}
 
String con = "jdbc:microsoft:sqlserver://192.168.0.199:1433;User=sa;
Password=bla;DatabaseName=testdb";
 
try {
  db_con = DriverManager.getConnection (con);
} catch ( SQLException se ) {
  out.println("Exception...(" + se.getMessage() + ")<br>-->");
}
%>
 
------------------------------------------------------
 
 
What do I have to do, to get it working with tomcat ? 
 
 
Thank you very much for your help !!! 

Greetings, 
Frank

-- 
Name:	Frank von Daak
eMail:	frank.fun@kpage.de	Homepage: http://www.kpage.de
eMail:  siteadmin@linux-dev.de	Homepage: http://www.linux-dev.de
"If Bill Gates had a nickel for every time Windows crashed...
    - oh wait, he does." 

Re: Tomcat and MsSQL

Posted by Frank von Daak <fr...@kpage.de>.
Hi,


Am Samstag, 30. August 2003 12:33 schrieb Christopher Williams:
> Question: Are you certain that SQL Server is listening on port 1433? I've
> seen it using port 1141.  Use the SQL Server network utility to check the
> TCP port.

yes, I'm sure it is, because I use the same jsp-file under websphere an it's 
working fine.
A "telnet 192.168.0.10 1433" also gives a response...


>
> ----- Original Message -----
> From: "Frank von Daak" <fr...@kpage.de>
> To: <to...@jakarta.apache.org>
> Sent: Saturday, August 30, 2003 10:51 AM
> Subject: Tomcat and MsSQL
>
> > Hi,
> >
> >
> > maybe, someone of you can help me...
> >
> > I try to port a webapplication from asp to java...
> >
> > First, I have used Websphere for this and everything worked ok, but then
> > I decided to use tomcat4 (both under debian-linux)
> >
> > My problem is the connection to a MSSQL-Database.
> >
> > As JDBC-Driver I'm using the  "Microsoft SQL Server 2000 Driver for
> > JDBC", which has an official linux-support. And I cn say, that it is
> > working very well with websphere...
> >
> > When I use the same jsp-files under tomcat, I get the following error,
>
> when
>
> > trying to connect the sql-server:
> >
> > [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
> >
> >
> > I have copied the 3 files "msbase.jar", "mssqlserver.jar" and
> > "msutil.jar"
>
> to
>
> > $CATALINA_HOME/common/lib and it seems, that tomcat can find them (as the
> > error message says)
> >
> > Here is the code, that I use to connect to the database:
> >
> > --------------------------------------------------
> >
> > <%@ page language="java" import="javax.sql.DataSource,java.sql.*"%>
> > <%
> >
> > Connection db_con;
> > Statement db;
> >
> > try {
> >   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
> > } catch (ClassNotFoundException e) {
> >   out.println("<h1>Der Datenbanktreiber konnte nicht gefunden werden:" +
> > e
>
> +
>
> > e.getMessage() + "</h1>" );
> > }
> >
> > String con = "jdbc:microsoft:sqlserver://192.168.0.199:1433;User=sa;
> > Password=bla;DatabaseName=testdb";
> >
> > try {
> >   db_con = DriverManager.getConnection (con);
> > } catch ( SQLException se ) {
> >   out.println("Exception...(" + se.getMessage() + ")<br>-->");
> > }
> > %>
> >
> > ------------------------------------------------------
> >
> >
> > What do I have to do, to get it working with tomcat ?
> >
> >
> > Thank you very much for your help !!!
> >
> > Greetings,
> > Frank
> >
> > --
> > Name: Frank von Daak
> > eMail: frank.fun@kpage.de Homepage: http://www.kpage.de
> > eMail:  siteadmin@linux-dev.de Homepage: http://www.linux-dev.de
> > "If Bill Gates had a nickel for every time Windows crashed...
> >     - oh wait, he does."
> >
> > ---------------------------------------------------------------------
> > 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

-- 
Name:	Frank von Daak
eMail:	frank.fun@kpage.de	Homepage: http://www.kpage.de
eMail:  siteadmin@linux-dev.de	Homepage: http://www.linux-dev.de
"If Bill Gates had a nickel for every time Windows crashed...
    - oh wait, he does." 

Re: Tomcat and MsSQL - Resolved

Posted by Frank von Daak <fr...@kpage.de>.
Hi,

after a very long search, I've found the solution for my problem.

I've installed tomcat4 directly from debian (.deb)
This installation has activatet the security-manager per default - and this 
caused the problem.

I've had to grant access to the IP and Port of the SQL-Server in the security 
manager.
After this I was able to open a Socket, but the driver still doesn't work, 
becaus of missing file permissions ([Microsoft][SQLServer 2000 Driver 
for JDBC]Error opening/loading com.microsoft.util.transliteration.properties.)

I've decided to deactivate the security manager - and now, everything is 
working well !

Greetings,
Frank


Am Samstag, 30. August 2003 12:33 schrieb Christopher Williams:
> Question: Are you certain that SQL Server is listening on port 1433? I've
> seen it using port 1141.  Use the SQL Server network utility to check the
> TCP port.
>
> ----- Original Message -----
> From: "Frank von Daak" <fr...@kpage.de>
> To: <to...@jakarta.apache.org>
> Sent: Saturday, August 30, 2003 10:51 AM
> Subject: Tomcat and MsSQL
>
> > Hi,
> >
> >
> > maybe, someone of you can help me...
> >
> > I try to port a webapplication from asp to java...
> >
> > First, I have used Websphere for this and everything worked ok, but then
> > I decided to use tomcat4 (both under debian-linux)
> >
> > My problem is the connection to a MSSQL-Database.
> >
> > As JDBC-Driver I'm using the  "Microsoft SQL Server 2000 Driver for
> > JDBC", which has an official linux-support. And I cn say, that it is
> > working very well with websphere...
> >
> > When I use the same jsp-files under tomcat, I get the following error,
>
> when
>
> > trying to connect the sql-server:
> >
> > [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
> >
> >
> > I have copied the 3 files "msbase.jar", "mssqlserver.jar" and
> > "msutil.jar"
>
> to
>
> > $CATALINA_HOME/common/lib and it seems, that tomcat can find them (as the
> > error message says)
> >
> > Here is the code, that I use to connect to the database:
> >
> > --------------------------------------------------
> >
> > <%@ page language="java" import="javax.sql.DataSource,java.sql.*"%>
> > <%
> >
> > Connection db_con;
> > Statement db;
> >
> > try {
> >   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
> > } catch (ClassNotFoundException e) {
> >   out.println("<h1>Der Datenbanktreiber konnte nicht gefunden werden:" +
> > e
>
> +
>
> > e.getMessage() + "</h1>" );
> > }
> >
> > String con = "jdbc:microsoft:sqlserver://192.168.0.199:1433;User=sa;
> > Password=bla;DatabaseName=testdb";
> >
> > try {
> >   db_con = DriverManager.getConnection (con);
> > } catch ( SQLException se ) {
> >   out.println("Exception...(" + se.getMessage() + ")<br>-->");
> > }
> > %>
> >
> > ------------------------------------------------------
> >
> >
> > What do I have to do, to get it working with tomcat ?
> >
> >
> > Thank you very much for your help !!!
> >
> > Greetings,
> > Frank
> >
> > --
> > Name: Frank von Daak
> > eMail: frank.fun@kpage.de Homepage: http://www.kpage.de
> > eMail:  siteadmin@linux-dev.de Homepage: http://www.linux-dev.de
> > "If Bill Gates had a nickel for every time Windows crashed...
> >     - oh wait, he does."
> >
> > ---------------------------------------------------------------------
> > 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

-- 
Name:	Frank von Daak
eMail:	frank.fun@kpage.de	Homepage: http://www.kpage.de
eMail:  siteadmin@linux-dev.de	Homepage: http://www.linux-dev.de
"If Bill Gates had a nickel for every time Windows crashed...
    - oh wait, he does." 

Re: Tomcat and MsSQL

Posted by Christopher Williams <cc...@ntlworld.com>.
Question: Are you certain that SQL Server is listening on port 1433? I've
seen it using port 1141.  Use the SQL Server network utility to check the
TCP port.

----- Original Message ----- 
From: "Frank von Daak" <fr...@kpage.de>
To: <to...@jakarta.apache.org>
Sent: Saturday, August 30, 2003 10:51 AM
Subject: Tomcat and MsSQL


> Hi,
>
>
> maybe, someone of you can help me...
>
> I try to port a webapplication from asp to java...
>
> First, I have used Websphere for this and everything worked ok, but then I
> decided to use tomcat4 (both under debian-linux)
>
> My problem is the connection to a MSSQL-Database.
>
> As JDBC-Driver I'm using the  "Microsoft SQL Server 2000 Driver for JDBC",
> which has an official linux-support. And I cn say, that it is working very
> well with websphere...
>
> When I use the same jsp-files under tomcat, I get the following error,
when
> trying to connect the sql-server:
>
> [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
>
>
> I have copied the 3 files "msbase.jar", "mssqlserver.jar" and "msutil.jar"
to
> $CATALINA_HOME/common/lib and it seems, that tomcat can find them (as the
> error message says)
>
> Here is the code, that I use to connect to the database:
>
> --------------------------------------------------
>
> <%@ page language="java" import="javax.sql.DataSource,java.sql.*"%>
> <%
>
> Connection db_con;
> Statement db;
>
> try {
>   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
> } catch (ClassNotFoundException e) {
>   out.println("<h1>Der Datenbanktreiber konnte nicht gefunden werden:" + e
+
> e.getMessage() + "</h1>" );
> }
>
> String con = "jdbc:microsoft:sqlserver://192.168.0.199:1433;User=sa;
> Password=bla;DatabaseName=testdb";
>
> try {
>   db_con = DriverManager.getConnection (con);
> } catch ( SQLException se ) {
>   out.println("Exception...(" + se.getMessage() + ")<br>-->");
> }
> %>
>
> ------------------------------------------------------
>
>
> What do I have to do, to get it working with tomcat ?
>
>
> Thank you very much for your help !!!
>
> Greetings,
> Frank
>
> -- 
> Name: Frank von Daak
> eMail: frank.fun@kpage.de Homepage: http://www.kpage.de
> eMail:  siteadmin@linux-dev.de Homepage: http://www.linux-dev.de
> "If Bill Gates had a nickel for every time Windows crashed...
>     - oh wait, he does."
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



Re: Tomcat and MsSQL

Posted by James Harman <ha...@comcast.net>.
Frank,

What linux user are you using to run tomcat and what user was websphere 
running under?  I am wondering if there are some weird firewalling 
issues here that allow websphere to open the socket but not tomcat.  It 
seems like a networking issue...

Of course, this might be totally the wrong direction too.

Is this the same jsp under tomcat and websphere?

James


Frank von Daak wrote:

>Hi,
>
> 
>maybe, someone of you can help me... 
> 
>I try to port a webapplication from asp to java... 
>
>First, I have used Websphere for this and everything worked ok, but then I 
>decided to use tomcat4 (both under debian-linux)
> 
>My problem is the connection to a MSSQL-Database.
> 
>As JDBC-Driver I'm using the  "Microsoft SQL Server 2000 Driver for JDBC", 
>which has an official linux-support. And I cn say, that it is working very 
>well with websphere...
> 
>When I use the same jsp-files under tomcat, I get the following error, when 
>trying to connect the sql-server:
>
>[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
> 
> 
>I have copied the 3 files "msbase.jar", "mssqlserver.jar" and "msutil.jar" to 
>$CATALINA_HOME/common/lib and it seems, that tomcat can find them (as the 
>error message says)
> 
>Here is the code, that I use to connect to the database:
> 
>--------------------------------------------------
> 
><%@ page language="java" import="javax.sql.DataSource,java.sql.*"%>
><%
> 
>Connection db_con;
>Statement db;
> 
>try {
>  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>} catch (ClassNotFoundException e) {
>  out.println("<h1>Der Datenbanktreiber konnte nicht gefunden werden:" + e + 
>e.getMessage() + "</h1>" );
>}
> 
>String con = "jdbc:microsoft:sqlserver://192.168.0.199:1433;User=sa;
>Password=bla;DatabaseName=testdb";
> 
>try {
>  db_con = DriverManager.getConnection (con);
>} catch ( SQLException se ) {
>  out.println("Exception...(" + se.getMessage() + ")<br>-->");
>}
>%>
> 
>------------------------------------------------------
> 
> 
>What do I have to do, to get it working with tomcat ? 
> 
> 
>Thank you very much for your help !!! 
>
>Greetings, 
>Frank
>
>  
>