jdbc:microsoft:sqlserver://cw-hwc:1433;DatabaseName=pubs;SelectMethod=direct你的机器名叫"cw-hwc"?去掉这个SelectMethod=direct
用这个吧:
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs

解决方案 »

  1.   

    <%@page contentType="text/html;charset=gb2312"%> 
    <% 
    //声名 
    java.sql.Connection sqlConn; 
    java.sql.Statement sqlStmt; 
    java.sql.ResultSet sqlRst;
    //regiester jdbc driver <APPLET CODE="<APPLET CODE="" WIDTH="" HEIGHT="">
    </APPLET>" WIDTH="" HEIGHT="">
    </APPLET>
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
    //connect to the database 
    sqlConn=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs;","sa","123");
    //create the driver handle 
    sqlStmt=sqlConn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY); 
    //excute sql 
    sqlRst=sqlStmt.executeQuery("select title_id,title,type from titles"); 
    %> 
    <html> 
    <head> 
    <title>Linux-JSP-JDBC-MYSQL TESTING -SELETCT copyright [email protected] </title> 
    </head> 
    <body> 
    <table border="1" cellspace ="0" align="center"> 
    <tr> 
    <th>title </th> 
    <th>type </th> 
    </tr> 
    <% while(sqlRst.next()) {%> 
    <tr> 
    <td> <%=sqlRst.getString(1)%></td> 
    <td><%=sqlRst.getString(2)%></td> 
    </tr> 
    <%}%> 
    </table> 
    </body> 
    </html> 
    <% 
    sqlRst.close(); 
    sqlStmt.close(); 
    sqlConn.close(); 
    %>  
    试了不行