用jsp+jdbc+sql server来实现登陆

图片说明

出现如上图的错误。求大神指点   本人小白   代码参照http://blog.csdn.net/jesse526/article/details/4377707、
用的是sql server2005

3个回答

缺少jar包吧,你导入sql server jar包了吗?

chenhchen1994
On_the_orad 回复QQ863017854: 不用jar 包的话 你怎么实现sql与项目的关联? 你可以导入一个sql server.jar试试
大约 4 年之前 回复
QQ863017854
QQ863017854 用的是2005 应该不用那个包吧
大约 4 年之前 回复

缺少或者驱动包版本不行。重新下一个版本高点的驱动包就好了。并且你的包应该加到项目里面去,build path一下就好了,一般不要放在桌面,放到项目里面就好了

应该是sql server2005驱动的jar包的问题,没有添加相应的jar包,或者jar包版本不对

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
用jsp+jdbc+sql server来实现登陆
![图片说明](https://img-ask.csdn.net/upload/201604/06/1459929609_292693.png) 出现如上图的错误。求大神指点 本人小白 代码参照http://blog.csdn.net/jesse526/article/details/4377707、 用的是sql server2005
用jsp+jdbc+sql server来实现登陆2
http://ask.csdn.net/questions/247737还是这个问题 没有解决 //定义jdbc的连接驱动 String url="jdbc:sqlserver://192.28.1.177,11008;DatabaseName=LD"; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); Connection conn = DriverManager.getConnection(url, dbname, dbpass); 是什么情况啊? 我sqljdbc也删干净了
jsp使用jdbc技术连接SQL Server2014时出现了一个问题,怎么解决?无法连接数据库
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
jsp中使用JDBC连接SQL Server数据库出现异常
![图片说明](https://img-ask.csdn.net/upload/201610/16/1476596966_480922.png) 数据库连接正常,包也导入了,然后我就不知道问题住在哪里了?
jsp+jdbc登录模块问题
登录页面: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'login.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h1>用户登录</h1> <hr> <form action="dologin.jsp" method="post"> <table> <tr> <td>用户名</td> <td><input type="text" name="username" /></td> <td>密码</td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2"><input type="submit" value="登陆"></td> <td> <input type="button" value="注册" onclick="window.location.href='register.jsp';"/> </td> </table> </form> </body> </html> 检查页面: <%@ page language="java" import="java.util.*" page contentType="text/html; charset=GB2312"%> <%@page import="java.sql.*" %> <%@page import="java.io.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JSP_JDBC_DEMO</title> </head> <body> <% Connection conn=null; Statement stmt=null; ResultSet res=null; boolean flag=false;//通过数据库匹配标识 String name_checked=null;//检查通过的用户名 %> <% try{ Class.forName("com.mysql.jdbc.Driver"); //加载驱动器 DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //注册mysql驱动器 String dbURL="jdbc:mysql://localhost:3306/test"; String dbUser="root"; String dbPwd="5438027"; conn=java.sql.DriverManager.getConnection(dbURL,dbUser,dbPwd); //建立数据库连接 stmt=conn.createStatement(); String u=request.getParameter("username"); //从上级页面获得用户名 String p=request.getParameter("userpassword"); //从上级页面获得密码 String sql="SELECT name FROM pass WHERE ACCOUNT=u AND PASSWORD=p";//组装sql语句 System.out.println(sql);//执行上述sql语句 res=stmt.executeQuery(sql); if(true==res.next())//只有查询得到结果才可进入循环 { flag=true; name_checked=res.getString(1);//获得查询出的用户 %> <h3>Debug_数据库查询结果<%=name_checked %></h3> <% } }catch(Exception e){ System.out.println(e); }finally{ //关闭连接 try{ /* res.close();//依次关闭 stmt.close(); conn.close(); */ /* res.close(); stmt.close(); conn.close(); */ }catch(Exception e) { } } %> <!-- 根据状态跳转 --> <% if(true==flag)//登陆成功 { %> <jsp:forward page="loginsucess.jsp"> <% } else//登陆失败 { %> <jsp:forward page="loginfail.jsp"> <% } %> </body> </html> 数据库里定义的是ACCOUNT 和PASSWORD 每次运行都会出现如下结果 HTTP Status 500 - /dologin.jsp (line: 1, column: 53) equal symbol expected type Exception report message /dologin.jsp (line: 1, column: 53) equal symbol expected description The server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: /dologin.jsp (line: 1, column: 53) equal symbol expected org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89) org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:217) org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162) org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:183) org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:479) org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:420) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:190) org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:193) org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722
JSP菜鸟问连接SQL SERVER 2008的问题
JSP代码 <%@ page contentType="text/html;charset=utf-8"%> <%@ page import="java.sql.*"%> <html> <body> <% Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); String url="jdbc:sqlserver://localhost:1433;DatabaseName=DbTest"; String username="sa"; String password="123456"; Connection conn= DriverManager.getConnection(url,username,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from Test"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1)%> 您的第二个字段内容为:<%=rs.getString(2)%> <%}%> <%out.println("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html> 出现问题如下: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /WebRoot/test.jsp at line 6 3: <html> 4: <body> 5: <% 6: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); 7: String url="jdbc:sqlserver://localhost:1433;DatabaseName=DbTest"; 8: 9: String username="sa"; Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause javax.servlet.ServletException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840) org.apache.jsp.WebRoot.test_jsp._jspService(test_jsp.java:110) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63) java.lang.Class.forName0(Native Method) java.lang.Class.forName(Unknown Source) org.apache.jsp.WebRoot.test_jsp._jspService(test_jsp.java:68) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs. Apache Tomcat/7.0.27 求解,各位高手,请赐教!郁闷到想自杀,搞了好久就是不通。
jsp jdbc方式连接SQL sever 操作数据库时没有返回的数据
<%@page language="java" import="java.util.*" import="java.sql.*" pageEncoding="UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>连接SQL Server数据库</title> </head> <body> <% Connection conn = null; Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Hsjy1"; String user = "sa"; String password = "12345678"; conn = DriverManager.getConnection(url,user,password); Statement st = conn.createStatement(); out.println("取得连接"); out.println("测试1"); out.println(conn.toString()); ResultSet rs = st.executeQuery("SELECT * FROM Hsjy1.dbo.dibu"); out.println("测试2"); while(rs.next()){ out.println("测试3"); out.println(rs.getString("Tel")+rs.getString("Fax")+rs.getString("beian")); } out.println("测试4"); rs.close(); conn.close(); out.println("测试5"); %> </body> </html>
sql-server问题
在用jsp和sql-server实现用户登录验证的时候,验证的代码为 <% String username=request.getParameter("username"); String password=request.getParameter("password"); try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); Connection conn= DriverManager.getConnection("jdbc.microsoft:sqlserver://localhost:1433;DatabaseName=luntan","sa","123"); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); String sql="select * from t_users where username='"+username+"'and password='"+password+"'"; ResultSet rs=stmt.executeQuery(sql); if(rs.next()) { response.sendRedirect("success.jsp"); } else { out.println("your password or userid is false"); response.sendRedirect("login.jsp"); } conn.close(); }catch(Exception e) { out.print(e); }; %> 登录的时候报这样的错误,数据库连接包三个全部放在tomcat的lib目录下面了,报错如下 java.sql.SQLException: No suitable driver found for jdbc.microsoft:sqlserver://localhost:1433;DatabaseName=luntan 是什么原因 [b]问题补充:[/b] 谢谢你的关注,不过我的问题已经写得很清楚了吧,三个jar包都已经放好了,问题已经解决了,是把 com.microsoft:sqlserver://localhost:1433;DatabaseName=luntan 换成jdbc:sqlserver//localhost。。。。 不过依然感谢你的提醒。。。。
使用springmvc时,为什么这样写代码无法得到SQL server中的数据
![图片说明](https://img-ask.csdn.net/upload/202003/16/1584369531_789077.png) # 在工程中,WebRoot中index.jsp可以查询得到SQL server的数据,而view中index.jsp却不能,求解,查询代码如下 ``` public class GoodsDao { @SuppressWarnings("finally") public ArrayList queryAllGoods(){ Connection conn=null; ArrayList goodss =new ArrayList(); try{ String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL= "jdbc:sqlserver://localhost:1433;DatabaseName=phoneShop"; String username="student"; String userpsd="888657"; Class.forName(driverName); conn=DriverManager.getConnection(dbURL,username,userpsd); String sql="select * from Goods"; Statement stat=conn.createStatement(); ResultSet rs=stat.executeQuery(sql); while(rs.next()){ Goods goods=new Goods(); goods.setGoods_id(rs.getInt("Goods_id")); goods.setGoods_name(rs.getString("Goods_name")); goods.setGoods_make(rs.getString("Goods_make")); goods.setGoods_type(rs.getString("Goods_type")); goods.setGoods_price(rs.getInt("Goods_price")); goods.setGoods_description(rs.getString("Goods_description")); goods.setStore_id(rs.getInt("Store_id")); goodss.add(goods); System.out.print(goods.getGoods_id()); System.out.print(goods.getGoods_name()); } rs.close(); stat.close(); } catch(Exception el){ el.printStackTrace(); } finally { try{ if(conn!=null){ conn.close(); conn=null; } } catch(Exception ex){ } return goodss; } } ```
[Microsoft][ODBC SQL Server Driver][SQL Server]?ַ? '??)' ?????Ų?????
2014-2-22 15:01:44 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/pro6] threw exception [An exception occurred processing JSP page /insert1.jsp at line 15 12: Connection conn=DriverManager.getConnection("jdbc:odbc:JSPDATA","sa","123"); 13: Statement stat=conn.createStatement(); 14: String sql="INSERT INTO T_STUDENT(STUNO,STUNAME,STUSEX) VALUES('0032','刘明','男')"; 15: out.println(stat.executeUpdate(sql)); 16: stat.close(); 17: conn.close(); 18: %> Stacktrace:] with root cause java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]?ַ? '??)' ?????Ų????? at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338) at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288) at org.apache.jsp.insert1_jsp._jspService(insert1_jsp.java:76) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
eclipse Java链接SQL server 驱动加载成功但数据库无法连接
![图片说明](https://img-ask.csdn.net/upload/201901/09/1547039291_230290.png) import java.sql.*; public class Main { public static void main(String [] args) { String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jsp"; String userName="sa"; String userPwd="1234"; try { Class.forName(driverName); System.out.println("加载驱动成功!"); }catch(Exception e){ e.printStackTrace(); System.out.println("加载驱动失败!"); } try{ Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); System.out.println("连接数据库成功!"); }catch(Exception e) { e.printStackTrace(); System.out.print("SQL Server连接失败!"); } } } ``` 网上给出的检测代码 ```
sqlserver2012无法通过jdbc连接MyElicpse 求个大神
使用sqljdbc.jar连接jdbc时: 通过端口 1433 连接到主机 127.0.0.1 的 TCP/IP 连接失败。错误:“Connection refused: connect。请验证连接属性。确保 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。 代码如下: String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";//驱动器 String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=xxxx"; String user = "sa";//用户名 String password = "sa";//密码 try { Class.forName(driver); // 加载数据库驱动 // 构建连接 Connection conn = DriverManager.getConnection(url, user, password); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); 防火墙已经关闭 没有阻止接口 telnet localhost 1433是通的 但是127.0.0.1 1433就提示连接端口:1433 失败 ping 127.0.0.1是没问题的 C盘etc/hosts中的对应localhost与127.0.0.1的内容为: # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost Sqlserver配置器已经打开 IIPALL的固定端口是1433 一直保持侦听状态 只有一个实例MSSQLSERVER windows事件日志上的错误是:服务器无法在 'any' <ipv4> 1434 上侦听。错误: 0x277a。若要继续,请通知您的系统管理员。 查看sqlserver 2012日志错误如下: Server failed to listen on 'any' <ipv4> 1434. Error: 0x277a. To proceed, notify your system administrator 错误: 26024,严重性: 16,状态: 1。 电脑已经重装成win7了 还是这个问题 sql可以和visual studio 2012连接 但是无法和MyElicpse连接 在cmd中执行netstat -ano 只有TCP [::]:1433接口在监听 找不到0.0.0.0:1433和127.0.0.1:1433这两个接口 1434只有UDP [::]:1434和0.0.0.0:1434 执行tasklist|findstr 2448(1433端口PID) 显示进程为sqlservr.exe 1433没有被占用 使用的jar包是sqljdbc4.jar ![图片说明](https://img-ask.csdn.net/upload/201610/01/1475290507_428583.png) ![图片说明](https://img-ask.csdn.net/upload/201610/01/1475290521_744595.png) ![图片说明](https://img-ask.csdn.net/upload/201610/01/1475290568_511606.png) ![图片说明](https://img-ask.csdn.net/upload/201610/01/1475290580_258520.png) ![图片说明](https://img-ask.csdn.net/upload/201610/01/1475290588_54854.png) 在之前使用win8的时候 有段时间是可以连接的 当时没有加入tomcat 大约有2到3个月没有使用这个jdbc 再拿出来学习jsp的时候 就一直提示这个错误 因为我要使用tomcat做jsp 要连接jdbc 所以这个问题很急 求大神解决一下啊 重装了好几次系统了 要崩溃了
通过写个类测试连接sqlserver2008数据库成功,在写jsp练习中失败
最简单的连接数据库,在写练习jsp登陆页面时,输入正确的用户名密码,跳转到失败页面。整个项目有一个警告是 Description Resource Path Location Type Classpath entry E:/ware/sqldrivers_for_vc/Microsoft SQL Server JDBC Driver 2.0/sqljdbc_2.0/chs/sqljdbc4.jar will not be exported or published. Runtime ClassNotFoundExceptions may result. AboutSql P/AboutSql Classpath Dependency Validator Message 控制台提示:java.lang.ClassNotFoundException: com.micsoft.sqlserver.jdbc.SQLServerDriver 我之前在一个类里测试了能连接数据库加载驱动。还没入门的菜鸟求教,真心累
sql server 的 for xml path查询出错
java web项目中 有代码如下 ``` String sql = "select a.dStareDate from JXZX_EAT_RECORD a where a.iState=1 and a.cCardNickNo='AA0005' for xml path('a')"; List ll = entityManager.createNativeQuery(sql).getResultList(); ``` 结果报出如下错误,在sql server 数据库中可以成功用这段sql查询。 Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) at sun.reflect.GeneratedMethodAccessor216.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:375) at com.sun.proxy.$Proxy163.getResultList(Unknown Source) at eiis.app.jxzx.servlet.JXZXCardManageService.getMainInfo(JXZXCardManageService.java:120) at eiis.app.jxzx.servlet.JXZXCardManageService$$FastClassBySpringCGLIB$$ec286876.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:667) at eiis.app.jxzx.servlet.JXZXCardManageService$$EnhancerBySpringCGLIB$$2f59bc87.getMainInfo(<generated>) at org.apache.jsp.app.jxzx.cardmanage.action_jsp$Action.getMain(action_jsp.java:306) at sun.reflect.GeneratedMethodAccessor258.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at eiis.util.Reflections.invokeMethod(Reflections.java:102) ... 104 more Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:196) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:160) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1885) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839) at org.hibernate.loader.Loader.doQuery(Loader.java:910) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355) at org.hibernate.loader.Loader.doList(Loader.java:2554) at org.hibernate.loader.Loader.doList(Loader.java:2540) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370) at org.hibernate.loader.Loader.list(Loader.java:2365) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:353) at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1909) at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:311) at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:141) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ... 119 more Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :' xml path('a')',expect IDENTIFIER, actual IDENTIFIER path : select a.dStareDate from JXZX_EAT_RECORD a where a.iState=1 and a.cCardNickNo='AA0005' for xml path('a') at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:726) at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:254) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:928) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:331) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:162) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186) ... 135 more Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :' xml path('a')',expect IDENTIFIER, actual IDENTIFIER path at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:232) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:407) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:145) at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:620) at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:574) at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:713) ... 147 more
Jsp+JavaBean+MySql实现登陆及增删改查出错。The value for the useBean class attribute bean.Sql
Jsp+JavaBean+MySql实现登陆及增删改查出错。The value for the useBean class attribute bean.SqlConn is invalid. 运行环境:Tomcat6.0+jdk1.6+MyEclipse6.0 报错信息: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: /ADMS/WebRoot/add.jsp(2,0) The value for the useBean class attribute bean.SqlConn is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200) org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392) org.apache.jasper.compiler.Node$Root.accept(Node.java:489) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336) org.apache.jasper.compiler.Generator.generate(Generator.java:3394) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210) org.apache.jasper.compiler.Compiler.compile(Compiler.java:306) 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:308) 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) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs. 我的代码 1.SqlConn.java package bean; import java.sql.*; public class SqlConn { private String url = "jdbc:mysql://localhost:3036/adms"; private String user = "root"; private String password = "root"; private Connection conn = null; private Statement stmt = null; private ResultSet rs = null; public SqlConn(){ try{ Class.forName("com.mysql.jdbc.Driver"); } catch(java.lang.ClassNotFoundException e){ System.err.println("SqlConn():"+e.getMessage()); } } public ResultSet executeQuery(String sql){ try{ conn = DriverManager.getConnection(url,user,password); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(sql); }catch(SQLException ex){ System.err.println("SqlConn.executeQuery:"+ex.getMessage()); } return rs; } public void executeUpdate(String sql){ try{ conn = DriverManager.getConnection(url,user,password); stmt = conn.createStatement(); stmt.executeUpdate(sql); stmt.close(); conn.close(); }catch(SQLException ex){ System.err.println("SqlConn.executeUpdate:"+ex.getMessage()); } } public void closeStmt(){ try{ stmt.close(); }catch(SQLException e){ e.printStackTrace(); } } public void closeConn(){ try{ conn.close(); }catch(SQLException e){ e.printStackTrace(); } } public static void main(String[] args) { // TODO Auto-generated method stub } } 2.login.jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%--使用SqlConn.class--%> <jsp:useBean id="sqlbean" scope="page" class="bean.SqlConn"/> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'login.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <form name="form1" action="loginto.jsp" method="post"> <table width="225" border="1" align="center"> <tbody> <tr> <td>用户名</td> <td><input type="text" name="username"> </td> </tr> <tr> <td>密码 </td> <td><input type="password" name="password"></td> </tr> <tr> <td colspan="2" align="center"> <input type="radio" checked="checked" value="1" name="role">用户 &nbsp;&nbsp;&nbsp; <input type="radio" value="0" name="role">管理员 </td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" value="登陆" name="login"> &nbsp;&nbsp; <input type="reset" value="重置" name="reset"> </td> </tr> </tbody> </table> </form> </body> </html> 3.loginto.jsp <%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%> <jsp:useBean id="sqlbean" scope="page" class="bean.SqlConn"/> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'loginto.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% String username = request.getParameter("username").trim(); String password = request.getParameter("password").trim(); String role = request.getParameter("role").trim(); try{ if(role.equals("0")) { String sql = "select * from admin where admin_id='"+username+"'and admin_psw='"+password+"'"; ResultSet rs = sqlbean.executeQuery(sql); if(rs.next()) response.sendRedirect("adms.jsp"); else out.println("错误的用户名或密码!"); } else if(role.equals("1")) { String sql = "select * from user where user_id='"+username+"'and user_psw='"+password+"'"; ResultSet rs = sqlbean.executeQuery(sql); if(rs.next()) out.println("您好,"+username); else out.println("错误的用户名或密码!"); } }catch(Exception ee){ ee.printStackTrace(); } %> </body> </html> 还有添加,删除,修改,查找等jsp页面。 我用JSP页面直接连接就能运行,没有错。只要是有JavaBean,就会报错。希望大家多多指教。 这个问题出现好久了,不仅这一个项目有这样的问题,所有的导入和新建的web project 只要有JavaBean都会有这样的错误。 搞不清是什么原因。数据库是SQLServer2000的时候也是这样的错误。
求助JSP出现异常The server encountered an internal error that prevented it from fulfilling this request.该怎么解决?
求大神帮忙! 报错信息如下: ![图片说明](https://img-ask.csdn.net/upload/202003/28/1585365350_64372.png) 报错页面checkUser.jsp代码: ``` <%@ page language="java" import="java.sql.*" contentType="text/html; charset=gbk" pageEncoding="gbk"%> <jsp:useBean id="dbcon" class="bean.DBcon" scope="request"/> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>查验</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <%String name=request.getParameter("name"); String pwd=request.getParameter("password"); Connection dbCon=dbcon.getConnection(); Statement stmt=dbCon.createStatement(); ResultSet rs=stmt.executeQuery("select * from userinfo where loginname="+name+" and password="+pwd); rs.last(); if(rs.next()){ session.setAttribute("name", "用户名"); session.setAttribute("pwd","密码"); response.sendRedirect("main.jsp"); }else{ response.sendRedirect("index.html"); } rs.close(); stmt.close(); dbCon.close(); %> </body> </html> ``` 报错语句为Statement stmt=dbCon.createStatement(); 但是真的不知道哪里错了呀 JavaBean——DBcon.java代码 ``` package bean; import java.sql.*; public class DBcon { private static final String DRIVER_CLASS="com.mysql.jdbc.Driver"; private static final String DATABASE_URL="jdbc:mysql://localhost:3306/books?useUnicode=true&characterEncoding=UTF-8"; private static final String DATABASE_USER="root"; private static final String DATABASE_PASSWORD="admin"; public static Connection getConnection(){ Connection dbConnection=null; try{ Class.forName(DRIVER_CLASS); dbConnection=DriverManager.getConnection(DATABASE_URL, DATABASE_USER, DATABASE_PASSWORD); }catch(Exception e){ e.printStackTrace(); } return dbConnection; } public static void closeConnection(Connection dbConnection){ try{ if(dbConnection!=null&&(!dbConnection.isClosed())){ dbConnection.close(); } }catch(SQLException sqlEx){ sqlEx.printStackTrace(); } } public static void closeResultSet(ResultSet res){ try{ if(res!=null){ res.close(); res=null; } }catch(SQLException e){ e.printStackTrace(); } } public static void closeStatement(PreparedStatement pStatement){ try{ if(pStatement!=null){ pStatement.close(); pStatement=null; } }catch(SQLException e){ e.printStackTrace(); } } } ``` 求大神帮忙!
jsp连接mysql时运行sql语句失败
四月 01, 2016 12:51:30 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/Test] threw exception [An exception occurred processing JSP page /register.jsp at line 49 46: 47: Connection conn = DriverManager.getConnection(url); 48: Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 49: ResultSet rs = stmt.executeQuery(sql); 50: 51: out.print("房间号"); 52: out.print("|"); Stacktrace:] with root cause com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '???' at line 1 at sun.reflect.GeneratedConstructorAccessor13.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:939) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2547) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2505) at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1370) at org.apache.jsp.register_jsp._jspService(register_jsp.java:132) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
JSP里连接数据库实现数据插入出错 求帮助。
[color=red]首先有两个页面insert.jsp和insert-success.jsp, 在insert.jsp里面连接数据库dbs,把表stu中的数据输出,然后添加一条记录,添加之后,跳转到insert_success.jsp 输出添加之后的stu里的所有记录。[/color] [u][color=green]表结构如下:[/color][/u] [img]http://dl.iteye.com/upload/attachment/298878/abc47b80-1a07-3f4a-8f57-678f0f13059d.jpg[/img] [u][color=green]insert.jsp源码[/color][/u][code="java"]<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <%@ page import="java.sql.*"%> <html> <head> <title>Insert Record Test...</title> </head> <body> <p> <font color=green>data inserting test........</font> </p> <hr color="brown"> <form action="insert_success.jsp" method="post"> <table > <tr><td>input StuID</td> <td><input type=text name="no"></td></tr> <tr><td>input StuName</td> <td><input type=text name="name"></td></tr> <tr><td>input ChineseScore</td> <td><input type=text name="chiscore"></td></tr> <tr><td>input MathScore</td> <td><input type=text name="mathscore"></td></tr> <tr><td>input EngScore</td> <td><input type=text name="engscore"></td></tr> </table> <br> <input type="submit" value="click to add record"/> </form> <hr color="brown"> <br> <p> <font color=green>添加之前的数据记录:</font></p> <% try{ Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e){} String ConStr = "jdbc:oracle:thin:@" ; String ServerName = "localhost"; String url =ConStr+ServerName+":1521:dbs"; String SqlQuery = "SELECT * FROM stu"; Connection con = DriverManager.getConnection(url,"soo","qq"); Statement sql=con.createStatement(); ResultSet rs = sql.executeQuery(SqlQuery); out.print("<table >"); out.print("<TH>学号"); out.print("<TH>姓名"); out.print("<TH>语文"); out.print("<TH>数学"); out.print("<TH>英语"); while (rs.next()) { out.print("<tr>"); out.print("<td>"+rs.getInt("no")+"</td>"); out.print("<td>"+rs.getString("name")+"</td>"); out.print("<td>"+rs.getInt("chinese")+"</td>"); out.print("<td>"+rs.getInt("math")+"</td>"); out.print("<td>"+rs.getInt("english")+"</td>"); out.print("</tr>"); } out.print("</table>"); rs.close(); sql.close(); con.close(); %> </body> </html>[/code] [u][color=green]insert_success.jsp源码[/color][/u][code="java"]<%@ page language="java" import="java.util.*" pageEncoding="gbk"%> <%@ page import="java.sql.*" %> <html> <head> <title>New Records!</title> </head> <body> <br> <% try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e){} String name = request.getParameter("name"); String no=request.getParameter("no"); String chiscore = request.getParameter("chiscore"); String mathscore = request.getParameter("mathscore"); String engscore = request.getParameter("engscore"); out.print("<table border>"); out.print("<TH>StuID"); out.print("<TH>StuName"); out.print("<TH>ChineseScore"); out.print("<TH>MathScore"); out.print("<TH>EnglishScore"); String ConStr = "jdbc:oracle:thin:@"; String ServerName = "localhost"; String url = ConStr+ServerName+":1521:dbs"; Connection con = DriverManager.getConnection(url,"soo","qq"); Statement sql = con.createStatement(); String SQLQuery = "INSERT INTO stu VALUES("+no+",'"+name+"',"+chiscore+","+mathscore+","+engscore+")"; out.print(SQLQuery); ResultSet rs = sql.executeQuery(SQLQuery); while(rs.next()){ out.print("<tr>"); out.print("<td>"+rs.getInt("no")+"</td>"); out.print("<td>"+rs.getString("name")+"</td>"); out.print("<td>"+rs.getInt("chinese")+"</td>"); out.print("<td>"+rs.getInt("math")+"</td>"); out.print("<td>"+rs.getInt("english")+"</td>"); out.print("</tr>"); } out.print("</table>"); rs.close(); con.close(); sql.close(); %> </body> </html>[/code] insert.jsp [img]http://dl.iteye.com/upload/attachment/298880/f80fcc0b-2eb4-3049-b682-4b02a73cf0f3.jpg[/img] [u][color=green]点击 click to add record之后出现如下错误:[/color][/u] [code="java"]HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /insert_success.jsp at line 38 35: ResultSet rs = sql.executeQuery(SQLQuery); 36: while(rs.next()){ 37: out.print("<tr>"); 38: out.print("<td>"+rs.getInt("no")+"</td>"); 39: out.print("<td>"+rs.getString("name")+"</td>"); 40: out.print("<td>"+rs.getInt("chinese")+"</td>"); 41: out.print("<td>"+rs.getInt("math")+"</td>"); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause javax.servlet.ServletException: java.sql.SQLException: ORA-00900: 无效 SQL 语句 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791) org.apache.jsp.insert_005fsuccess_jsp._jspService(insert_005fsuccess_jsp.java:113) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause java.sql.SQLException: ORA-00900: 无效 SQL 语句 oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283) oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278) oracle.jdbc.driver.T4C8Odscrarr.receive(T4C8Odscrarr.java:214) oracle.jdbc.driver.T4CStatement.doDescribe(T4CStatement.java:723) oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3276) oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1914) oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1563) org.apache.jsp.insert_005fsuccess_jsp._jspService(insert_005fsuccess_jsp.java:92) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs. -------------------------------------------------------------------------------- Apache Tomcat/6.0.29[/code] 实在不知道哪里错了。。希望路过的大家帮忙看下。
使用java web 实现登录功能,servlet跳转jsp失败,页面出现空白,求大神解决!!!
package dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import dbc.JdbcUtil; public class UserDao { public boolean register(String username,String userpw,String identity)throws Exception{ Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; conn = JdbcUtil.getConnection(); String sql = "select * from user where username=? and userpw=? and identity=?"; ps = conn.prepareStatement(sql); ps.setString(1,username); ps.setString(2, userpw); ps.setString(3, identity); rs = ps.executeQuery(); if (rs.next()) return true; else return false; } } `package dbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class JdbcUtil { private static String driver; private static String url; private static String user; private static String password; private static Properties pr = new Properties(); private JdbcUtil() { } // ��Ƹù�����ľ�̬��ʼ�����еĴ��룬�ô�����װ����ʱִ�У���ִֻ��һ�� static { try { pr.load(JdbcUtil.class.getClassLoader().getResourceAsStream( "db.properties")); driver = pr.getProperty("driver"); url = pr.getProperty("url"); user = pr.getProperty("user"); password = pr.getProperty("password"); Class.forName(driver); } catch (Exception e) { throw new ExceptionInInitializerError(e); } } // ��ƻ�����Ӷ���ķ���getConnection() public static Connection getConnection() throws SQLException { return DriverManager.getConnection(url, user, password); } // ����ͷŽ���������ӵķ���free() public static void free(ResultSet rs, Statement st, Connection conn) { try { if (rs != null) { rs.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (st != null) { st.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException e) { } } } } } ```package servlets; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import dao.UserDao; import vo.User; import java.sql.*; public class RegistServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; /** * Constructor of the object. */ public RegistServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String un=request.getParameter("username"); String uw=request.getParameter("userpw"); String iden=request.getParameter("identity"); User uu=new User(un,uw,iden); UserDao c1 = null; PrintWriter out = null; try { if(c1.register(uu.getUsername(), uu.getUserpw(), uu.getIdentity())) request.getRequestDispatcher("/output.jsp").forward(request, response); else out.print("<script> alert(\"登录失败!\"); </script>"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } // TODO Auto-generated catch block /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } } ```package vo; public class User { private String username; private String userpw; private String identity; public User(String username, String userpw, String identity) { this.identity=identity; this.username=username; this.userpw=userpw; // TODO Auto-generated constructor stub } public String getUsername(){return username;} public String getUserpw(){return userpw;} public String getIdentity(){return identity;} public void setUsername(String username){this.username=username;} public void setUserpw(String userpw){this.userpw=userpw;} public void setIdentity(String identity){this.identity=identity;} } ```driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/LibSytem?useUnicode=true&characterEncoding=utf-8 user=root password=960714 ```<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head><title>登录页面</title> </head> <body> <center><h1>图书馆用户登录</h1></center> <center> <hr width="100%" size="1" color="black"> <form action="RegistServlet" method="post"> <table> <tr><td>登录名:</td><td><input type="text" name="username"></td></tr> <tr><td>登录密码:</td><td><input type="password" name="userpw"></td></tr> <tr><td>身份:</td><td><select name="identity"> <option selected>用户</option> <option>管理员</option> </select></td></tr> <tr><td><input type="submit" value="登录"></td></tr> </table> </form> </center> </body> </html> ```<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>成功</title> </head> <body> This is my JSP page. <br> </body> </html> ``` ``` ``` `` ``` ``` ``` ``` ``` ``` ``` ``` ```
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
深析Synchronized关键字(小白慎入,深入jvm源码,两万字长文)
目录一、synchronized基础1.1synchronized的使用1.1示例1.2验证1.2.1 普通方法和代码块中使用this是同一个监视器(锁),即某个具体调用该代码的对象1.2.2 静态方法和代码块中使用该类的class对象是同一个监视器,任何该类的对象调用该段代码时都是在争夺同一个监视器的锁定1.2、synchronized的特点二、synchronized进阶2.1对象头2.2sy
GitHub 总星 4w+!删库?女装?表情包?这些沙雕中文项目真是我每天快乐的源泉!
大家好,我是 Rocky0429,一个喜欢在 GitHub 上瞎逛的蒟蒻… 好看的皮囊千篇一律,有趣的灵魂没有底线。作为全球最大的同性交友网站,GayHub GitHub 上不止有鲜活的代码,秃头的算法,还有很多拥有有(sha)趣(diao)灵魂的宝藏。 还记得我之前给大家介绍的 Sorry 项目嘛,一个可以自己做表情包的项目,这个的沙雕程度在下面这些项目面前只能算弟弟。虽然说沙雕不分国...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
20道你必须要背会的微服务面试题,面试一定会被问到
这篇博客总结了面试中最常见的微服务面试题,相信对你有所帮助。
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
C语言数字图像处理---1.4直方图拉伸和直方图均衡化
本篇将延续上一篇的内容,对直方图进行扩展,讲述直方图拉伸和直方图均衡化两个内容,并通过简单的C语言来实现这两个基础功能,让初学者通俗易懂。
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
没用过这些 IDEA 插件?怪不得写代码头疼
使用插件,可以提高开发效率。对于开发人员很有帮助。这篇博客介绍了IDEA中最常用的一些插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
推荐一些有趣的在线编程游戏
1.Robocode 让坦克们互相博弈的游戏,你可以看到它们飞奔,碾碎一切挡道的东西。机器人配有雷达与火炮,选手在躲避对手进攻的同时攻击对手,以此来较量得分的多少。这个游戏很有意思,曾经令我沉迷… 你可以用Java、Scala、C#等编程语言,编写人工智能程序,驱动机器人。 2.Code Combat Code Combat是一款学习编程的角色扮演游戏。每一关都用任务的形式设立目标,用实时的反馈...
工作十年的数据分析师被炒,没有方向,你根本躲不过中年危机
2020年刚刚开始,就意味着离职潮高峰的到来,我身边就有不少人拿着年终奖离职了,而最让我感到意外的,是一位工作十年的数据分析师也离职了,不同于别人的主动辞职,他是被公司炒掉的。 很多人都说数据分析是个好饭碗,工作不累薪资高、入门简单又好学。然而今年34的他,却真正尝到了中年危机的滋味,平时也有不少人都会私信问我: 数据分析师也有中年危机吗?跟程序员一样是吃青春饭的吗?该怎么保证自己不被公司淘汰...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
张朝阳回应迟到 1 分钟罚 500:资本家就得剥削员工
loonggg读完需要2分钟速读仅需 1 分钟大家我,我是你们的校长。前几天,搜狐的董事局主席兼 CEO 张朝阳和搜狐都上热搜了。原因很简单,就是搜狐出了“考勤新规”。一封搜狐对员工发布...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
立即提问