Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    53

    Red face Unanswered: connecting to sql 2000 using jdbc

    Hello All

    I'm trying to set up a connection to sql server 2000 using java in a jsp page. but i get the following error when loading through Tomcat 5.0


    Thanks for any help


    My code is as follows:

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

    <HTML>
    <HEAD><TITLE>SQL</TITLE></HEAD>
    <BODY bgcolor="#ffffff">
    <%
    //String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;

    //Class.forName(driver);

    String url = "jdbc:mircosoft:sqlserver://MYSERVERNAME:1433;DatabaseName=MYDATABASENAME";

    Connection con = DriverManager.getConnection(url,"sa","password");

    Statement stmt = con.createStatement();

    ResultSet rs = stmt.executeQuery("SELECT * FROM myTestTable");
    %>

    <h1>sql results</h1>

    <table border="1">
    <th>idcol</th>
    <th>textcol</th>
    <%
    while (rs.next())
    {
    String idCol = rs.getString("idcol");
    String timeCol = rs.getString("textcol");
    %>
    <tr>
    <td><%=idCol %></td>
    <td><%=timeCol %></td>
    </tr>
    <%
    }
    %>
    </table>

    <%
    rs.close();
    stmt.close();
    con.close();
    %>
    </BODY>
    </HTML>


    And this is the error i get :

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: No suitable driver
    org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:867)
    org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:800)
    org.apache.jsp.sqlConnection_jsp._jspService(sqlCo nnection_jsp.java:113)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


    root cause

    java.sql.SQLException: No suitable driver
    java.sql.DriverManager.getConnection(DriverManager .java:532)
    java.sql.DriverManager.getConnection(DriverManager .java:171)
    org.apache.jsp.sqlConnection_jsp._jspService(sqlCo nnection_jsp.java:58)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


    note The full stack trace of the root cause is available in the Tomcat logs.


    --------------------------------------------------------------------------------

    Apache Tomcat/5.0.18

  2. #2
    Join Date
    Aug 2003
    Location
    West
    Posts
    101
    It looks like either the class is not on the classpath or the .jar the class is in is not on the classpath.

  3. #3
    Join Date
    Jan 2004
    Posts
    53
    Sorted it now

  4. #4
    Join Date
    Feb 2004
    Posts
    1

    JDBC connection String

    I am connecting my Java app to SQL server 2000 names instance Database. I am currently using the following string:

    jdbc:inetdae7:dbvs100:1551

    Now that our Database is using Names instances for HA and failover I need to have an instance name entered.

    jdbc:inetdae7:dbvs100\inst1:1551 does not work

    jdbc:inetdae7:dbvs100:1551?instance=inst1 does not work either


    any help is appreciated.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •