首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

啊!小弟我是这样用Jsp连接数据库的,为什么总是错啊?

2013-09-11 
高手指点啊!!!我是这样用Jsp连接数据库的,为什么总是错啊???%Class.forName(com.micrsoft.jdbc.sqlserve

高手指点啊!!!我是这样用Jsp连接数据库的,为什么总是错啊???
<%
Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
Connection con= DriverManager.getConnection(url,"sa","123");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
ResultSet rs;
String sql;
String title="我要书网站管理系统";
%>


错误信息:
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 4 in the jsp file: /common/connectdb.jsp
Connection cannot be resolved to a type
1: <%
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;


An error occurred at line: 4 in the jsp file: /common/connectdb.jsp
DriverManager cannot be resolved
1: <%
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;


An error occurred at line: 5 in the jsp file: /common/connectdb.jsp
Statement cannot be resolved to a type
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;
8: String title="鎴戣涔︾綉绔欑鐞嗙郴缁?;


An error occurred at line: 5 in the jsp file: /common/connectdb.jsp
conn cannot be resolved
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;
8: String title="鎴戣涔︾綉绔欑鐞嗙郴缁?;


An error occurred at line: 5 in the jsp file: /common/connectdb.jsp
ResultSet.TYPE_SCROLL_SENSITIVE cannot be resolved to a type
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;
8: String title="鎴戣涔︾綉绔欑鐞嗙郴缁?;


An error occurred at line: 5 in the jsp file: /common/connectdb.jsp
ResultSet.CONCUR_UPDATABLE cannot be resolved to a type
2: Class.forName("com.micrsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  


6: ResultSet rs;
7: String sql;
8: String title="鎴戣涔︾綉绔欑鐞嗙郴缁?;


An error occurred at line: 6 in the jsp file: /common/connectdb.jsp
ResultSet cannot be resolved to a type
3: String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=bookshop";
4: Connection con= DriverManager.getConnection(url,"sa","123");
5: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
6: ResultSet rs;
7: String sql;
8: String title="鎴戣涔︾綉绔欑鐞嗙郴缁?;
9: %>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



[解决办法]
"com.micrsoft.jdbc.sqlserver.SQLServerDriver" microsoft 少了一个“o”
[解决办法]
Connection cannot be resolved to a type 
DriverManager cannot be resolved to a type 
没有引入SQL Server的驱动包

还有url错误
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行