我写了断JSP代码如下:
<% 
Connection conn = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String strConn="jdbc:sqlserver://localhost:1433;DatabaseName=Mtesst";
String strUser="sa"; 
String strPassword="111";
conn=DriverManager.getConnection(strConn,strUser,strPassword);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from tb_employee";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
可以正常运行,但是为什么在顶部加入
<%@ page import="mondrian.olap.*"%>
就不能正常运行了?
错误提示是:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 10 in the jsp file: /test.jsp
The type Connection is ambiguous
7: <body>
8: 
9: <% 
10: Connection conn = null;
11: 
12: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
13: 

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【ls_thy】截止到2008-07-14 20:24:17的历史汇总数据(不包括此帖):
    发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:---------------------结分的百分比:---------------------
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    是用什么编辑器??如果是JBuilder  那么 你点击JSP 的属性里把Check JSP for errors at build-time 前面的勾去掉!
      

  3.   

    因为你 mondrian.olap 这个包中也有一个叫 Connection 的接口或类,它分不清你用的 Connection 是 mondrian.olap java.sql 哪个包中的。解决方法:Connection -> java.sql.Connection 即给接口加上包名限定,防止 ambiguous(含糊不清的)。
      

  4.   

    谢谢了,果然是Connection引用的问题。