这是我写的一个数据库连接测试.....不知道为什么在IE不能显示啊 .....也不报错呀....
      大虾帮个忙呀 .....
     <%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>jdbc connect of sqlserver</title>
</head>
<body>
<% Connection conn=null;
   Statement stm=null;
   ResultSet rs=null;
   String url=
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=myapp";
   String user="sa";
   String pwd="admin";
   try{
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
   }catch(ClassNotFoundException e) {e.printStackTrace();}
   try{
      conn=DriverManager.getConnection(url,user,pwd);
      stm=conn.createStatement();
      rs=stm.executeQuery("select * from studinfo");
      while(rs.next()){
          out.println("<tr><td>"+rs.getInt(1)+"</td>");
          out.println("<td>"+rs.getString(2)+"</td></tr>");
      }
   }catch(SQLException ex){ ex.getMessage();}
   finally{
        if(rs!=null) rs.close();
        if(stm!=null) stm.close();
        if(conn!=null) conn.close();
   }
%>
</body>
</html>     但是我放在JDK上测试是没问题的呀 ....import java.sql.*;
public class DbTest{
     private Connection conn;
     private Statement stm;
     private ResultSet rs;
     private String driver;
     private String url;
     private String user;
     private String pwd;
     public DbTest(){
          driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
          url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=myapp";
          user="sa";
          pwd="admin";
          init();
     }
     public void init(){
          try{
              Class.forName(driver);
              System.out.println("driver is ok");
              conn=DriverManager.getConnection(url,user,pwd);
              System.out.println("connection is ok");
              stm=conn.createStatement();
              rs=stm.executeQuery("select * from studinfo");
              while(rs.next())
                  System.out.println(rs.getInt("studid"));
           }catch(Exception e){
               e.printStackTrace();
           }
     }
     public static void main(String args[]){
          new DbTest();
     }
}             这样是可以得到结果...........
      小弟刚学啊 ...不明白哦 .....麻烦给帮个忙哈 !!!!!!!

解决方案 »

  1.   

    did you put your driver in to the libary package(it named 'lib' in tomcat app server)?you' better show the err information up to us.
      

  2.   

    页面上不报错啊....没显示错误信息啊!!!!
       我把那三个JAR文件放在了 WEB-INF\lib文件夹下了呀 ...
        在common\lib\ 也放了呀 .....
       我用jdbcodbc桥连access都没问题哦!!!!
      

  3.   

    呵呵....我找个答案了 ....
       我忘了把数据库文件放到 app server 下了 ....
      谢谢你们的提醒了!!!!