SQLServer 2000 Driver for JDBC Unable to connect ????????????

kennethcky
kennethcky used Ask the Experts™
on
Hi,

I'm trying to insert records into the database and display them in the browser.
I'm getting the following error. I used
-Tomcat4.0
-Microsoft SQL 2000 Server
-Microsoft SQLServer 2000 Driver for JDBC
-jdk1.3.1_02
-Windows 2000 Professional

Should I change something in the server.xml, or add something to the classpath

I just added into the classpath the MS SQL 2000 Drivers namely
(located inside \web-inf\classes\lib\*,jar)
-msbase.jar
-mssqlserver.jar
-msutil.jar
but still to no avail


FYI, it able to work using Ms Access but NOT MS SQL 2000 Server. I use JSP to
call JavaBean to connect to database. Am I missing something over here?

PLS HELP ......................

Below is part of the CONNECTION STRING
****************************************************************************
String dbURL = "jdbc:microsoft:sqlserver://holla:1433,DatabaseName=sample";
String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
Class.forName(dbURL);
dbCon = DriverManager.getConnection(dbURL,"sa","jonny");
****************************************************************************

500 Error:
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to

connect.  Invalid URL.
      at

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
      at org.apache.jsp.sql$jsp._jspService(sql$jsp.java:168)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at

org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain

.java:247)
      at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:19

3)
      at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
      at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at

org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
      at

org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
      at java.lang.Thread.run(Thread.java:484)


root cause

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect.  

Invalid URL.
      at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
      at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
      at java.sql.DriverManager.getConnection(DriverManager.java:517)
      at java.sql.DriverManager.getConnection(DriverManager.java:199)
      at SQLBean.DbBean.connect(DbBean.java:19)
      at org.apache.jsp.sql$jsp._jspService(sql$jsp.java:111)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at

org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain

.java:247)
      at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:19

3)
      at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
      at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at

org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at

org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at

org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
      at

org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
      at java.lang.Thread.run(Thread.java:484)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Below are the codes related to above error message
Pls help me to solve it i'm getting crazy about this error

JAVA CODE


package SQLBean;

import java.sql.*;  
import java.io.*;  


public class DbBean {

  String dbURL = "jdbc:microsoft:sqlserver://holla:1433,DatabaseName=sample";
  String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
  private Connection dbCon;

  public DbBean(){  
       super();        
       }

  public boolean connect() throws ClassNotFoundException,SQLException{
          Class.forName(dbDriver);
          dbCon = DriverManager.getConnection(dbURL,"sa","jonny");
          return true;
        }

 

  public void close() throws SQLException{
        dbCon.close();
       }

  public ResultSet execSQL(String sql) throws SQLException{

                    Statement s = dbCon.createStatement();
                    ResultSet r = s.executeQuery(sql);
                    return (r == null) ? null : r;
                    }

  public int updateSQL(String sql) throws SQLException{                    
                   Statement s = dbCon.createStatement();
                   int r = s.executeUpdate(sql);
                   return (r == 0) ? 0 : r;
                }

}
   
--------------------------------------------------------------------------------------
JSP PAGE

<HTML>  
<HEAD><TITLE>DataBase Search</TITLE></HEAD>  
<BODY>

<%@ page language="Java" import="java.sql.*" %>  

<jsp:useBean id="db" scope="request" class="SQLBean.DbBean" />

<jsp:setProperty name="db" property="*" />

 <%!  
         ResultSet rs = null ;
         ResultSetMetaData rsmd = null ;
         int numColumns ;
         int i;  
%>

<center>  
<h2> Results from </h2>  
<hr>  
<br><br>  
<table>

<%
   db.connect();

try {
          rs = db.execSQL("select * from employee");  
          i = db.updateSQL("UPDATE employee set CLUB = 'MOUNTAIN' where CID='102'");
          out.println(i);
        }catch(SQLException e) {
              throw new ServletException("Your query is not working", e);        
              }  

          rsmd = rs.getMetaData();
          numColumns = rsmd.getColumnCount();
          for(int column=1; column <= numColumns; column++){  
                    out.println(rsmd.getColumnName(column));
           }  
%>

<%        
      while(rs.next()) {  
%>      
<%= rs.getString("EMPNO") %>
<BR>  
<%
                }  
%>  
<BR>  
<%

   db.close();

%>

Done

</table>

</body>

</HTML>
Distinguished Expert 2018

Commented:
 Are you sure that the JDBC driver expects the jdbc URL on this format: String dbURL = "jdbc:microsoft:sqlserver://holla:1433,DatabaseName=sample";

  Better check the documentation. It seems it is an invalid format you are trying to send.
Java Developer
Top Expert 2010
Commented:
Try a semicolon instead of a comma in your jdbc url:

String dbURL = "jdbc:microsoft:sqlserver://holla:1433;DatabaseName=sample";
Mick BarryJava Developer
Top Expert 2010

Commented:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial