是不是ODBC数据源的问题?设置成系统的

解决方案 »

  1.   

    希望你不是故意的,
    如果你是故意的那么先鄙视你一下。
    如果你不是故意的,那么我会耐心地告诉你,因为你的程序里面有全角的空格,通不过编译,楼上的打假难道都看不出来是编译通不过吗。我已经改好了。
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="java.sql.*" %>
    <html>
      <body>
    <%
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev";
    String user="bn";
    String password="bn";
    Connection conn= DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    String sql="select userid,name from user_info";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){%>
        您的第一个字段内容为:<%=rs.getString(1)%><br>
        您的第二个字段内容为:<%=rs.getString(2)%><br>
    <%}%>
    <%out.print("数据库操作成功,恭喜你");%>
    <%
    rs.close();
    stmt.close();
    conn.close();
    %>
      </body>
    </html>
      

  2.   

    为什么不用ODBC:JDBC桥来连接呢?
      

  3.   

    难道用ODBC连接比直接连接要好一点吗?
    能否介绍一下啊?
      

  4.   

    5楼的网友说我原来的jsp中有全角的空格,我用他改过的也出现了下列问题HTTP Status 500 -type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?? 'bn' ???????: ???? SQL Server ??????
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:83)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?? 'bn' ???????: ???? SQL Server ??????
    com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
    com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    java.sql.DriverManager.getConnection(DriverManager.java:512)
    java.sql.DriverManager.getConnection(DriverManager.java:171)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:52)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs各位帮帮忙呀
      

  5.   

    这里还有全角啊
    String sql="select userid,name from user_info";
    程序是没有问题的,
    检查一下是否把msbase,mssqlserver,msutil三个jar包放到到tomcat\common\lib目录下了
      

  6.   

    我已经确定代码里没有全角了,下面是代码
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="java.sql.*" %>
    <html>
      <body>
    <%
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev";
    String user="bn";
    String password="bn";
    Connection conn= DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    String sql="select userid,phone from user_info";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){%>
        您的第一个字段内容为:<%=rs.getString(1)%><br>
        您的第二个字段内容为:<%=rs.getString(2)%><br>
    <%}%>
    <%out.print("数据库操作成功,恭喜你");%>
    <%
    rs.close();
    stmt.close();
    conn.close();
    %>
      </body>
    </html>可是还是有同样的错误
    HTTP Status 500 -type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?? 'bn' ???????: ???? SQL Server ??????
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:83)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?? 'bn' ???????: ???? SQL Server ??????
    com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
    com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
    com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
    com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    java.sql.DriverManager.getConnection(DriverManager.java:512)
    java.sql.DriverManager.getConnection(DriverManager.java:171)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:52)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the 
    Apache Tomcat/5.0.27 logs请各位再帮帮我呀,我实现没发现还有什么错误