jsp连接数据库过程中出现SQL异常!,mysql和Tomcat也确认启动了,但还是一直报错!

代码如下:

<%@ page import="java.sql.*" %>

<%@ page import="java.util.*"%>

<%@ page import="java.text.*"%>

<%@ page import="java.io.*"%>

<%
String url="jdbc:mysql://localhos:3306/mydatabase";

String userName="root";

String password="471414388";

Connection conn= null;

String stu_id=request.getParameter("num");

Statement stmt=null;

String sql=null;

try{

Class.forName("com.mysql.jdbc.Driver");

}

catch(ClassNotFoundException e){out.println("加载驱动器类出现异常");}

try{

conn=DriverManager.getConnection(url,userName,password);    
stmt=conn.createStatement();
sql="select * from student";
ResultSet rs=stmt.executeQuery(sql);

%>

<%
while(rs.next()){

int id=rs.getInt(1);
String name=rs.getString(2);
String address=rs.getString(3);
String birthdate=rs.getString(4);
%>
<tr>
    <td><%=id%></td>
    <td><%=name%></td>
    <td><%=address%></td>
    <td><%=birthdate%></td>
</tr>
<%
}
rs.close();
stmt.close();
}catch(SQLException e){out.println("连接数据库过程中出现SQL异常");}
finally{
try{
if(conn != null)
conn.close();}catch(SQLException e){
out.println("关闭数据库连接时出现SQL异常");}
}%>

已经把connector放在lib下了,但是还是一直SQL异常的错,到底应该怎么办嘤嘤嘤QAQ

图片说明

图片说明

很急!求救!QAQ

itspoppysu
itspoppysu 解决啦!在url后面加?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC即可
4 个月之前 回复

3个回答

你看你的url,localhost

itspoppysu
itspoppysu 啊!谢谢谢谢!但是改过来之后依然报错QAQ
4 个月之前 回复

报错信息是啥啊??没有报错日志吗

把 catch 分支中的自定义的打印信息去掉,改成 e.printStack() 打印堆栈异常再根据异常进行排查。

itspoppysu
itspoppysu 我哭辽
4 个月之前 回复
itspoppysu
itspoppysu org.apache.jasper.JasperException: Unable to compile class for JSP: JSP文件:[/byName.jsp] 的第 [50] 行发生了一个错误 The method printStack() is undefined for the type SQLException 47: } 48: rs.close(); 49: stmt.close(); 50: }catch(SQLException e){e.printStack() ;} 51: finally{ 52: try{ 53: if(conn != null)
4 个月之前 回复
itspoppysu
itspoppysu 改成e.printStack()之后报错说什么这个方法QAQ
4 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
JSP连接ACCESS数据库出错,tomcat
用的是JdbcOdbc,已配置School系统数据源,尝试了网上好多方法,都没有解决,上火。。 这是tomcat出错信息: org.apache.jasper.JasperException: An exception occurred processing JSP page /index1.jsp at line 28 25: <body> 26: <% 27: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 28: Connection conn=DriverManager.getConnection("jdbc:odbc:School"); 29: Statement stat=conn.createStatement(); 30: String sql="insert into T_STUDENT(STUNO,STUNAME,STUSEX) values ('4','老虎','男')"; 31: int i=stat.executeUpdate(sql); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412) 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: [Microsoft][ODBC Microsoft Access 驱动程序] 不能打开数据库 '(未知的)'。应用程序可能无法识别该数据库,或文件可能损坏。 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794) org.apache.jsp.index1_jsp._jspService(index1_jsp.java:102) 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:388) 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: [Microsoft][ODBC Microsoft Access 驱动程序] 不能打开数据库 '(未知的)'。应用程序可能无法识别该数据库,或文件可能损坏。 sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source) sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source) sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) org.apache.jsp.index1_jsp._jspService(index1_jsp.java:86) 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:388) 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) 这是JSP源码: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:School"); Statement stat=conn.createStatement(); String sql="insert into T_STUDENT(STUNO,STUNAME,STUSEX) values ('4','老虎','男')"; int i=stat.executeUpdate(sql); out.println("cheng gong+ "+i+" hang"); stat.close(); conn.close();
出现内部错误 jsp连接数据库
错误码Type Exception Report Message org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WebRoot._001_jsp Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception org.apache.jasper.JasperException: org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WebRoot._001_jsp org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:572) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:390) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WebRoot._001_jsp org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:177) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:381) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause java.lang.ClassNotFoundException: org.apache.jsp.WebRoot._001_jsp java.net.URLClassLoader.findClass(URLClassLoader.java:381) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:59) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:381) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Note The full stack trace of the root cause is available in the server logs. Apache Tomcat/9.0.7 代码 <%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%> <%@ page import="java.io.*,java.util.*,java.sql.*"%> <%@ page import="javax.servlet.http.*,javax.servlet.*" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <html> <head> <title>SELECT ����</title> </head> <body> <!-- JDBC �����������ݿ� URL ���ݿ���û��������룬��Ҫ�����Լ������� useUnicode=true&characterEncoding=utf-8 ��ֹ�������� --> <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/runoob?useUnicode=true&characterEncoding=gb2312" user="root" password="ppnn13%"/> <sql:query dataSource="${snapshot}" var="result"> SELECT * from websites; </sql:query> <h1>JSP ���ݿ�ʵ�� - ����̳�</h1> <table border="1" width="100%"> <tr> <th>ID</th> <th>վ����</th> <th>վ���ַ</th> </tr> <c:forEach var="row" items="${result.rows}"> <tr> <td><c:out value="${row.id}"/></td> <td><c:out value="${row.name}"/></td> <td><c:out value="${row.url}"/></td> </tr> </c:forEach> </table> </body> </html>
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)
mysql和jsp连接问题,500错误
jsp连接数据库制作一个商品网站,登录界面输入账号密码登录500错误,每一个连接数据库的界面都是500,求大佬解答,就是下面这个c'w 登录反馈结果 com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.UnknownHostException MESSAGE: local STACKTRACE: java.net.UnknownHostException: local at java.net.InetAddress.getAllByName0(InetAddress.java:1157) at java.net.InetAddress.getAllByName(InetAddress.java:1083) at java.net.InetAddress.getAllByName(InetAddress.java:1019) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:246) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:271) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771) at com.mysql.jdbc.Connection.(Connection.java:1555) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:207) at myservlet.control.HandleLogin.doPost(HandleLogin.java:40) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) ** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago.
jsp 链接MySQL数据库使用excuteUpdate()方法出错
<%@ page language="java" import="java.sql.*,java.io.*" pageEncoding="UTF-8"%> <% String driverNmae="com.mysql.jdbc.Driver"; String username="root"; String password="123456"; String dbName="book"; String tableNmae="bookinfo"; String url="jdbc:mysql://localhost:3306/"+dbName+"?user="+username+"&password="+password; Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn=DriverManager.getConnection(url); Statement stmt=conn.createStatement();//执行 SQL语句并返回它所生成结果的对象 //定义变量接收数据 String bookname=request.getParameter("name"); String publisher=request.getParameter("publisher"); String price=request.getParameter("price"); bookname=new String(bookname.getBytes("iso-8859-1"));//对输入的数据进行编码 publisher=new String(publisher.getBytes("iso-8859-1")); price=new String(price.getBytes("iso-8859-1")); if(bookname.equals("")|publisher.equals("")|price.equals("")){ response.sendRedirect("index.jsp"); }else{ String sql="insert into bookinfo(bookname,publisher,price) values("+bookname+","+publisher+","+price+")"; stmt.executeUpdate(sql);//**就是这句老是报错** out.print("数据添加成功"); } stmt.close(); conn.close(); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <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> </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 /MyJsp.jsp at line 23 20: response.sendRedirect("index.jsp"); 21: }else{ 22: String sql="insert into bookinfo(bookname,publisher,price) values("+bookname+","+publisher+","+price+")"; 23: stmt.executeUpdate(sql);**** 24: out.print("鏁版嵁娣诲姞鎴愬姛"); 25: } 26: stmt.close(); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417) 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) root cause javax.servlet.ServletException: 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 '?,清å�Žå¤§å­¦å‡ºç‰ˆç¤?,12.00)' at line 1 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.MyJsp_jsp._jspService(MyJsp_jsp.java:109) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) 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) 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 '?,清å�Žå¤§å­¦å‡ºç‰ˆç¤?,12.00)' at line 1 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) java.lang.reflect.Constructor.newInstance(Constructor.java:513) com.mysql.jdbc.Util.handleNewInstance(Util.java:406) com.mysql.jdbc.Util.getInstance(Util.java:381) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564) com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485) org.apache.jsp.MyJsp_jsp._jspService(MyJsp_jsp.java:78) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) 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.13 logs. -------------------------------------------------------------------------------- Apache Tomcat/6.0.13
关于数据库连接(c3p0连接mysql)出现的问题
本来是想通过jsp页面添加一个数据,跳转到访问serlvlet页面通过jbutils连接mqsql保存数据,但是我检查了c3p0的配置文件和datasource对象,queryrunner对象都可以正常新建,具体问题找不到,谢谢大家了这是访问页面的报错代码 HTTP Status 500 - java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in type Exception report message java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in description The server encountered an internal error that prevented it from fulfilling this request. exception java.lang.RuntimeException: java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in serviceimp.FoodTypeService.save(FoodTypeService.java:62) servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65) servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44) servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:643) javax.servlet.http.HttpServlet.service(HttpServlet.java:723) root cause java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in daoimp.FoodTypeDao.save(FoodTypeDao.java:36) serviceimp.FoodTypeService.save(FoodTypeService.java:59) servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65) servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44) servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:643) javax.servlet.http.HttpServlet.service(HttpServlet.java:723) root cause java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:200) org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:437) daoimp.FoodTypeDao.save(FoodTypeDao.java:34) serviceimp.FoodTypeService.save(FoodTypeService.java:59) servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65) servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44) servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:643) javax.servlet.http.HttpServlet.service(HttpServlet.java:723) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.39 logs.
用tomcat运行jsp文件连接出现如下错误提示
觉得是连接数据库出了问题,但具体什么问题,如何解决请指教 ![图片说明](https://img-ask.csdn.net/upload/201908/08/1565239316_237856.png) 错提示: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DKTK]] after start() had already been called. The second call will be ignored. Exception in thread "Timer-3" org.springframework.dao.DataAccessResourceFailureException: Cannot open connection; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open connection at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:625) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912) at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904) at com.dk.edu.jpkc.dao.impl.BaseDaoImpl.getAll(BaseDaoImpl.java:113) at com.dk.edu.jpkc.service.impl.BaseServiceImpl.getAll(BaseServiceImpl.java:50) at com.dk.edu.jpkc.common.ConnectTask.run(ConnectTask.java:19) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: org.hibernate.exception.JDBCConnectionException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573) at org.hibernate.loader.Loader.doQuery(Loader.java:696) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:921) at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) ... 8 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) at com.mysql.jdbc.Util.getInstance(Util.java:384) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929) at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2226) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2127) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:208) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ... 24 more Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284) at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2172) ... 38 more
求助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(); } } } ``` 求大神帮忙!
eclipse在运行的时候不能在数据库添加内容
我在做添加内容的时候提示SQL语句输入错误,但是我查不出来哪里有错,求各位大佬的帮助!! 一下分别为代码和错误提示。(非图片部分为dealadd.jsp的代码) 代码:![图片说明](https://img-ask.csdn.net/upload/202003/09/1583767337_533916.jpg) ```<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!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>Insert title here</title> </head> <body> <% String username = null; String sno = null; String password = null; String birthday = null; String tel = null; String character = null; username = request.getParameter("username"); sno = request.getParameter("sno"); password = request.getParameter("password"); birthday = request.getParameter("birthday"); tel = request.getParameter("tel"); character = request.getParameter("character"); try{ //将前一个页面提交来的数据写入数据库 Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/mydatabase"; Connection con = DriverManager.getConnection(url,"root","root"); Statement stat = con.createStatement(); stat.executeUpdate("insert into user (sno,username,password,character,birthday,tel) values ('" +sno+"','"+username+"','"+password+"','"+character+"','"+birthday+"','"+tel+"')"); stat.close(); stat.close(); out.print("添加成功!"); }catch(Exception ex){ ex.printStackTrace(); } %> </body> </html> ``` 错误提示: 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 'character,birthday,tel) values ('null','null','null','null','null','null')' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485) at org.apache.jsp.dealadd_jsp._jspService(dealadd_jsp.java:115) 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:218) 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:958) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) 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 'character,birthday,tel) values ('003','123','123','123','123','2334234')' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485) at org.apache.jsp.dealadd_jsp._jspService(dealadd_jsp.java:115) 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:218) 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:958) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)
IDEA中Tomcat服务器重启后报异常怎么解决?
``` java -Dcatalina.base=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2 "-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0" "-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp" -Dcom.sun.management.jmxremote= -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2\jmxremote.password -Dcom.sun.management.jmxremote.access.file=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2\jmxremote.access -Djava.rmi.server.hostname=127.0.0.1 -cp "C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\tomcat-juli.jar" org.apache.catalina.startup.Bootstrap start [2020-02-28 12:09:58,816] Artifact Filter:war exploded: Waiting for server connection to start artifact deployment... 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/7.0.96 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Jul 24 2019 13:00:10 UTC 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 7.0.96.0 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 8 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 6.2 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Program Files\Java\jdk1.7.0_15\jre 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.7.0_15-b03 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 7.0 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcom.sun.management.jmxremote= 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcom.sun.management.jmxremote.port=1099 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcom.sun.management.jmxremote.ssl=false 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2\jmxremote.password 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\wx\.IntelliJIdea2017.3\system\tomcat\Tomcat_7_0_96_study_2\jmxremote.access 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.rmi.server.hostname=127.0.0.1 二月 28, 2020 12:09:59 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_15\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\oracle\applocation\bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;D:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.7.0_15\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Java\jdk1.8.0_201\bin;C:\AppServ\Apache24\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin;C:\Users\wx\AppData\Local\Microsoft\WindowsApps;;. 二月 28, 2020 12:09:59 下午 org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] 二月 28, 2020 12:09:59 下午 org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 486 ms 二月 28, 2020 12:09:59 下午 org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina 二月 28, 2020 12:09:59 下午 org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.96 二月 28, 2020 12:09:59 下午 org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] 二月 28, 2020 12:09:59 下午 org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] 二月 28, 2020 12:09:59 下午 org.apache.catalina.startup.Catalina start INFO: Server startup in 45 ms Connected to server [2020-02-28 12:09:59,866] Artifact Filter:war exploded: Artifact is being deployed, please wait... 二月 28, 2020 12:10:00 下午 org.apache.catalina.deploy.WebXml setVersion WARNING: Unknown version string [4.0]. Default version will be used. 二月 28, 2020 12:10:00 下午 org.apache.catalina.core.ContainerBase addChildInternal SEVERE: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1018) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:619) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1426) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) at sun.rmi.transport.Transport$1.run(Transport.java:177) at sun.rmi.transport.Transport$1.run(Transport.java:174) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:173) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> Servlet01 in servlet mapping at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3511) at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3486) at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1452) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1300) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5606) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ... 42 more 二月 28, 2020 12:10:00 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke SEVERE: Exception invoking method manageApp java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1022) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:619) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1426) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) at sun.rmi.transport.Transport$1.run(Transport.java:177) at sun.rmi.transport.Transport$1.run(Transport.java:174) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:173) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) 二月 28, 2020 12:10:00 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke SEVERE: Exception invoking method createStandardContext javax.management.RuntimeOperationsException: Exception invoking method manageApp at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:309) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:619) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1426) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) at sun.rmi.transport.Transport$1.run(Transport.java:177) at sun.rmi.transport.Transport$1.run(Transport.java:174) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:173) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1022) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) ... 33 more [2020-02-28 12:10:00,214] Artifact Filter:war exploded: Error during artifact deployment. See server log for details. 二月 28, 2020 12:10:09 下午 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager 二月 28, 2020 12:10:09 下午 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager has finished in 143 ms ``` ![图片说明](https://img-ask.csdn.net/upload/202002/28/1582873199_268932.png) **上面是异常代码,下面是一部分截图,然后访问jsp页面或servlet页面也不会404,就只是空白页面**
tomcat+mysql,插入中文乱码问题
在数据库中直接写入中文,页面查询能显示中文,但是页面做插入操作时乱码,用数据库连接管理器查看,显示乱码 这是插入语句 ``` insert into message (name,message) value ('sun','阿萨德') ``` 问题 应该是 tomcat 向数据库 传输数据 编码不正确 ,怎么改? ``` <% String userName = request.getParameter("userName"); String passWord = request.getParameter("passWord"); String message = request.getParameter("message"); if(message!=null){ message = new String(message.getBytes("ISO-8859-1"),"utf-8"); } String insert = "insert into message (name,message) value ('"+userName+"','"+message+"')"; String sql = "select * from message"; if(userName!=null && passWord!=null){ Class.forName("com.mysql.jdbc.Driver"); Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test","root",""); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery(sql); while(rs.next()) { out.print(rs.getString(2)+" 说:"+rs.getString(3)+"\n在:"+rs.getString(4)+"\n"); } if(message!=null){ stmt.executeUpdate(insert); } rs.close(); stmt.close(); conn.close(); }else{ response.sendRedirect("/index.jsp"); } %> ```
jsp 连接 mysql 查询 报错500
源代码: <%@ page contentType="text/html; charset=GB2312"%> <%@ page import="java.util.*,java.sql.*"%> <% request.setCharacterEncoding("GB2312"); //链接数据库程序 Class.forName("org.gjt.mm.mysql.Driver"); //Connection conn = DriverManager.getConnection( -------SQL桥 // "jdbc:odbc:bookshoplk", "sa", ""); Connection connect = DriverManager .getConnection("jdbc:mysql://localhost:3306/bookshop?user=root&password=root&useUnicode=true&characterEncoding=GBK"); //Statement stmt = conn.createStatement( ---------- SQL的连接 // ResultSet.TYPE_SCROLL_INSENSITIVE, // ResultSet.CONCUR_READ_ONLY); Statement stmt = connect.createStatement(); ResultSet rs = null; //rs结果集 String s_where = (String) session.getAttribute("s_where"); String s_bookid = ""; String s_bookname = ""; String s_author = ""; String s_publisher = ""; String s_price = ""; int i_totalnum = 0;//书籍数量 rs = stmt //String sql=“SELECT * FROM `show`” .executeQuery("select count(distinct bookid) from'book left join publisher on book.publisherid=publisher.publisherid where bookid is not null " + s_where); rs.next(); i_totalnum = rs.getInt(1); %> <% if (i_totalnum != 0) {//显示的是查询结果 %> <table border=1> <tr> <td width=30%>书号</td> <td width=30%>书名</td> <td width=10%>作者</td> <td width=15%>出版社</td> <td width=30%>价格</td> </tr> <% rs = stmt .executeQuery("select * from book left join publisher on book.publisherid=publisher.publisherid where bookid is not null " + s_where + " order by bookid "); for (int i = 0; i <= i_totalnum; i++) { if (!rs.isLast()) { rs.next(); s_bookid = rs.getString("bookid"); s_bookname = rs.getString("bookname"); s_author = rs.getString("author"); s_price = rs.getString("price"); s_publisher = rs.getString("name"); %> <tr> <td><%=s_bookid%></td> <td><%=s_bookname%></td> <td><%=s_author%></td> <td><%=s_publisher%></td> <td><%=s_price%></td> </tr> <% } } %> </table> <% } else { String temp = "没有您要找的书,请重新搜索!返回。"; temp = java.net.URLEncoder.encode(temp.toString(), "gbk"); response.sendRedirect("error.jsp?error=" + temp); //显示,为查询到结果 %> <!-- --- <table> <tr> <td> <img src="../img/sorry.jpeg" /> </td> </tr> <tr> <td> 没有您要找的书,请 <a href="search.jsp">重新搜索</a> </td> </tr> </table> --> <% } %> 错误提; type Exception report message An exception occurred processing JSP page /cust/booklist.jsp at line 25 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 /cust/booklist.jsp at line 25 22: String s_price = ""; 23: int i_totalnum = 0;//�鼮���� 24: rs = stmt //String sql=��SELECT * FROM `show`�� 25: .executeQuery("select count(distinct bookid) from'book left join publisher on book.publisherid=publisher.publisherid where bookid is not null " 26: + s_where); 27: rs.next(); 28: i_totalnum = rs.getInt(1); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:567) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:454) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause javax.servlet.ServletException: com.mysql.jdbc.exceptions.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 ''book left join publisher on book.publisherid=publisher.publisherid where booki' at line 1 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:908) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:837) org.apache.jsp.cust.booklist_jsp._jspService(booklist_jsp.java:220) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause com.mysql.jdbc.exceptions.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 ''book left join publisher on book.publisherid=publisher.publisherid where booki' at line 1 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) com.mysql.jdbc.Connection.execSQL(Connection.java:3277) com.mysql.jdbc.Connection.execSQL(Connection.java:3206) com.mysql.jdbc.Statement.executeQuery(Statement.java:1232) org.apache.jsp.cust.booklist_jsp._jspService(booklist_jsp.java:117) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/8.0.20 logs.
javaweb连接数据库代码出现问题,请带佬帮我解决一下
代码: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="java.sql.*" %> <% 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 'stuCtrl.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> <% //提取表单 request.setCharacterEncoding("utf-8"); String stuNO=request.getParameter("stuNO"); String stuName=request.getParameter("stuName"); String sex=request.getParameter("sex"); String [] hobby=request.getParameterValues("hobby"); String grade=request.getParameter("grade"); String email=request.getParameter("email"); System.out.println("1"); String hobbies=""; if(hobby!=null){ for(String hh:hobby) hobbies+=hh+" "; } //关联数据库 String driver="com.mysql.jdbc.Driver"; String url="jdbc:mysql://localhost:3306/testdb2?user=root&password=321282" + "&useUnicode=true&characterEncoding=UTF8&useSSL=true"; Connection conn=null; try{//1.加载驱动 Class.forName(driver); //2.获得连接对象 conn=DriverManager.getConnection(url); System.out.println("2"); String sql="insert into student(stuNO,stuName,sex,hobby,grade,email) values(?,?,?,?,?,?)"; PreparedStatement postmt =conn.prepareStatement(sql); postmt.setString(1, stuNO); postmt.setString(2, stuName); postmt.setString(3, sex); postmt.setString(4, hobbies); postmt.setString(5, grade); postmt.setString(6, email); System.out.println("3"); int n=postmt.executeUpdate();//执行sql if(n>0){ session.setAttribute("stuName",stuName); response.sendRedirect("index.jsp"); }else{ request.setAttribute("mess","没有添加成功,请重新输入"); request.getRequestDispatcher("insertStu.jsp").forward(request, response); } } catch(Exception e){ request.setAttribute("mess","没有添加成功,请重新输入"); request.getRequestDispatcher("insertstudent.jsp").forward(request, response); e.printStackTrace(); } %> </body> </html> 错误截图 ![图片说明](https://img-ask.csdn.net/upload/201910/31/1572526079_706229.png)
eclipse 运行时添加数据库内容报错
我在sql语句上报错,但是我初步出来哪里有问题,麻烦各位大佬帮忙! ![图片说明](https://img-ask.csdn.net/upload/202003/09/1583767924_444054.jpg)![图片说明](https://img-ask.csdn.net/upload/202003/09/1583767936_75404.jpg) 错误代码: 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 'character,birthday,tel) values ('null','null','null','null','null','null')' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485) at org.apache.jsp.dealadd_jsp._jspService(dealadd_jsp.java:115) 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:218) 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:958) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) 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 'character,birthday,tel) values ('003','123','123','123','123','2334234')' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485) at org.apache.jsp.dealadd_jsp._jspService(dealadd_jsp.java:115) 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:218) 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:958) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)
MySQL数据库连接问题。
[code="java"][/code]我是个Java开发的初学者,最近开始自学Servlet/JSP编程,参考的是孙鑫老师编的《Servlet/Jsp深入详解——基于Tomcat的Web开发》。 在学习“第4章数据库访问”时遇到了问题,我按照书上的代码编写了一个CreateDBServlet.java用于连接数据库,编译是没问题的。进行了部署和配置后,访问时出错了,浏览器显示的错误信息如下: HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) org.sunxin.ch04.servlet.CreateDBServlet.doGet(CreateDBServlet.java:61) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910) com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923) com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273) com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031) com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718) com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298) com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) java.sql.DriverManager.getConnection(DriverManager.java:525) java.sql.DriverManager.getConnection(DriverManager.java:171) org.sunxin.ch04.servlet.CreateDBServlet.doGet(CreateDBServlet.java:44) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 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.18 logs. -------------------------------------------------------------------------------- Apache Tomcat/6.0.18 CreateDBServlet代码如下: [code="java"]package org.sunxin.ch04.servlet; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CreateDBServlet extends HttpServlet { private String userUrl; private String userName; private String password; public void init() throws ServletException { String driverClass=getInitParameter("driverClass"); userUrl=getInitParameter("userUrl"); userName=getInitParameter("userName"); password=getInitParameter("password"); try { Class.forName(driverClass); } catch (ClassNotFoundException ce) { throw new ServletException("加载数据库驱动失败!"); } } public void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException { Connection conn=null; Statement stmt=null; try { conn=DriverManager.getConnection(userUrl,userName,password); stmt=conn.createStatement(); stmt.executeUpdate("create database bookstore"); stmt.executeUpdate("use bookstore"); stmt.executeUpdate("create table bookinfo(id INT not null primary key,title VARCHAR(50) not null,author VARCHAR(50) not null,bookconcern VARCHAR(50) not null,publish_date DATE not null,price FLOAT(4,2) not null,amount SMALLINT,remark VARCHAR(200))ENGINE=InnoDB"); stmt.addBatch("insert into bookinfo values(1,'Java Web 详解','孙鑫','电子工业出版社','2006-4-20',99.00,35,null)"); stmt.addBatch("insert into bookinfo values(2,'Struts 2深入详解','孙鑫','电子工业出版社','2008-6-15',79.00,20,null)"); stmt.addBatch("insert into bookinfo values(3,'Servlet/JSP详解','孙鑫','电子工业出版社','2008-7-1',79.00,10,null)"); stmt.executeBatch(); resp.setContentType("text/html;charset=GBK"); PrintWriter out=resp.getWriter(); out.println("数据库创建成功!"); out.close(); } catch (SQLException se) { throw new ServletException(se); } finally { if(stmt!=null) { try { stmt.close(); } catch (SQLException se) { se.printStackTrace(); } stmt=null; } if(conn!=null) { try { conn.close(); } catch (SQLException se) { se.printStackTrace(); } conn=null; } } } }[/code] web.xml文件如下: [code="java"]<?xml version="1.0" encoding="gb2312"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>createDB</servlet-name> <servlet-class>org.sunxin.ch04.servlet.CreateDBServlet</servlet-class> <init-param> <param-name>driverClass</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </init-param> <init-param> <param-name>userUrl</param-name> <param-value>jdbc:mysql://localhost:3306</param-value> </init-param> <init-param> <param-name>userName</param-name> <param-value>root</param-value> </init-param> <init-param> <param-name>passord</param-name> <param-value>12345678</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>createDB</servlet-name> <url-pattern>/createdb</url-pattern> </servlet-mapping> </web-app> [/code]
myeclipse 10.7中用jsp无法连接mysql 5.5 单独用java文件却可以~
我是要做一个简单的查询数据库操作,在win10 64位系统用tomcat 7 myeclipse 10.7用jsp无法连接数据库,提示NO SUITBLE Driver和空指针 但是我换成win 7 32位系统用tomcat 6 myeclipse 8,5 时就可以查询了,两边的代码和操作都一样~~求大神赐教~! select.jsp中出错代码段:<% Student student=new Student(); //创com.ch6.dal.Studne的对象,命名为student **List<StudentInfo> list=student.getList();** //该方法返回一个LIST集合(显示这里出错) for(StudentInfo info:list){ %> Student.java如下:public class Student { Conn conn=new Conn(); /*获取学生列表*/ public List<StudentInfo> getList() throws SQLException{ List<StudentInfo> list=new ArrayList<StudentInfo>(); String sql="select * from student order by number asc"; ResultSet rs=conn.executeQuery(sql); **while(rs.next()){//这里显示空指针** StudentInfo info=new StudentInfo(); info.setId(rs.getInt("Id")); info.setNumber(rs.getString("Number")); info.setName(rs.getString("Name")); info.setAddress(rs.getString("Address")); info.setSex(rs.getString("Sex")); info.setPhone(rs.getString("Phone")); info.setEmail(rs.getString("Email")); list.add(info); } conn.close(); return list; }
Java WEB 连接数据库的登录界面失败?
使用Eclipse做登陆界面,连接MySQL 8.0,测试过连接数据库应该是成功的,可能是struts配置有问题,新手不知道问题出在哪里,请帮忙看一下代码,我标注几个我可能出问题又不知道怎么改的地方 //login.jsp //此处可能是表单中form的action属性有问题? ``` <%@ page contentType="text/html; charset=gb2312" language="java"%> <html> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <head> <title>图书馆管理系统</title> <link href="CSS/style.css" rel="stylesheet"> <script language="javascript"> function check(form){ if (form.name.value==""){ alert("请输入用户名称");form.name.focus();return false; } if (form.pwd.value==""){ alert("请输入密码");form.pwd.focus();return false; } } </script> </head> <body> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="tableBorder"> <tr> <td width="1000" height="545" align="center" background="Images/login.png"> <table width="1000" height="345" aligh="center" ></table> <form name="form1" method="post" action="manager.do?action=login"> <table width="400" height="200" align="left"> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"> 用户名</td> <td height="37" width="150"> <input name="name" type="text" class="logininput" id="name" size="27"> </td> </tr> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"> 密码 </td> <td height="37" width="150"> <input name="pwd" type="text" class="logininput" id="pwd" size="27"> </td> </tr> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"></td> <td height="37" width="200"> <input name="Submit" type="submit" class="btn_grey" value="确定" onClick="return check(form1)"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="Submit3" type="reset" class="btn_grey" value="重置"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="Submit2" type="button" class="btn_grey" value="关闭" onClick="window.close();"> </td> </tr> </table> </form> </td> <tr> <td align="center" height="50" bgcolor="#3A3A3A" class="word_login">CopyRight &copy; 2019版权所有 xx图书馆<br> </td> </tr> </table> </body> </html> ``` //Manager.java ``` package com.action; import org.apache.struts.action.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.actionForm.ManagerForm; import com.dao.ManagerDAO; import javax.servlet.http.HttpSession; public class Manager extends Action { private ManagerDAO managerDAO = null; public Manager() { this.managerDAO = new ManagerDAO(); } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String action = request.getParameter("action"); // System.out.println("获取的查询字符串:" + action); if (action == null || "".equals(action)) { return mapping.findForward("error"); } else if ("login".equals(action)) { return managerLogin(mapping, form, request, response); } request.setAttribute("error", "操作失败!"); return mapping.findForward("error"); } // 管理员身份验证 public ActionForward managerLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ManagerForm managerForm = (ManagerForm) form; //将接收到的表单信息强制转换成ActionForm类型 managerForm.setAd_name(managerForm.getAd_name()); managerForm.setAd_pwd(managerForm.getAd_pwd()); int ret = managerDAO.checkManager(managerForm); System.out.print("验证结果ret的值:" + ret); if (ret == 1) { //将登录到系统的管理员名称保存到session HttpSession session = request.getSession(); session.setAttribute("manager", managerForm.getAd_name()); return mapping.findForward("managerLoginok"); } else { request.setAttribute("error", "您输入的管理员名称或密码错误!"); return mapping.findForward("error"); } } } ``` //ManagerForm ``` package com.actionForm; import org.apache.struts.action.ActionForm; public class ManagerForm extends ActionForm { private int ad_id; private String ad_name; private String ad_pwd; public ManagerForm() { } public int getAd_id() { return ad_id; } public void setAd_id(int ad_id) { this.ad_id=ad_id; } public String getAd_name() { return ad_name; } public void setAd_name(String ad_name) { this.ad_name=ad_name; } public String getAd_pwd() { return ad_pwd; } public void setAd_pwd(String ad_pwd) { this.ad_pwd=ad_pwd; } } ``` //ManagerDAO ``` package com.dao; import com.core.ChStr; import com.core.ConnDB; import java.util.*; import com.actionForm.ManagerForm; import java.sql.*; public class ManagerDAO { private ConnDB conn = new ConnDB(); //管理员身份验证 public int checkManager(ManagerForm managerForm) { int flag = 0; ChStr chStr=new ChStr(); String sql = "SELECT * FROM Ad_info where ad_name='" + chStr.filterStr(managerForm.getAd_name()) + "'"; ResultSet rs = conn.executeQuery(sql); try { if (rs.next()) { String pwd = chStr.filterStr(managerForm.getAd_pwd()); //获取输入的密码并过滤输入字符串中的危险字符 if (pwd.equals(rs.getString(3))) { flag = 1; } else { flag = 0; } }else{ flag = 0; } } catch (SQLException ex) { flag = 0; }finally{ conn.close(); } return flag; } } ``` //ConnDB ``` package com.core; import java.io.InputStream; import java.sql.*; import java.util.Properties; public class ConnDB { public Connection conn=null; public Statement stmt=null; public ResultSet rs=null; private static String propFileName="/com/connDB.properties"; private static Properties prop=new Properties(); private static String dbClassName="com.mysql.cj.jdbc.Driver"; private static String dbUrl="jdbc:mysql://223.80.110.29:3306/sys_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL"; private static String dbUserName="root"; private static String dbPassword=""; //加载资源文件 public ConnDB() { try { InputStream in=getClass().getResourceAsStream(propFileName); prop.load(in); dbClassName=prop.getProperty("DB_CLASS_NAME","com.mysql.cj.jdbc.Driver"); dbUrl=prop.getProperty("DB_URL","jdbc:mysql://localhost:3306/db_librarysys?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL"); dbUserName=prop.getProperty("DB_USERNAME"); dbPassword=prop.getProperty("DB_PASSWORD"); } catch(Exception e){ e.printStackTrace(); } } public static Connection getConnection() { Connection conn=null; try { //加载数据库驱动 Class.forName(dbClassName); conn=DriverManager.getConnection(dbUrl,dbUserName,dbPassword); } catch(Exception ee) { ee.printStackTrace(); } if(conn==null) { System.err.println("警告:DbConnectionManager.getConnection()获得数据库链接失败.\r\n\r\n链接类型:"+dbClassName+"\r\n链接位置:"+dbUrl); } return conn; } //执行查询语句 public ResultSet executeQuery(String sql) { try { conn=getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); /*ResultSet.CONCUR_READ_ONLY 不能用结果集更新数据库中的表 ResultSet.TYPE_SCROLL_INSENSITIVE 结果集的游标可以上下移动,当数据库变化时,当前结果集不变。 */ rs=stmt.executeQuery(sql); } catch(SQLException ex){ System.err.println(ex.getMessage()); } return rs; } //执行更新操作 添加修改删除数据 public int executeUpdate(String sql) { int result=0;//更新的行数 try { conn=getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); result=stmt.executeUpdate(sql); }catch(SQLException ex) { result=0; } return result; } public void close() { try { if(rs!=null) { rs.close(); } if(stmt!=null) { stmt.close(); } if(conn!=null) { conn.close(); } }catch(Exception e) { e.printStackTrace(System.err); } } } ``` //struts-config ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <form-beans> <form-bean name="managerForm" type="com.actionForm.ManagerForm" /> <form-bean name="ParameterForm" type="com.actionForm.ParameterForm" /> </form-beans> <action-mappings type="org.apache.struts.action.ActionMapping"> <action name="managerForm" path="/manager" scope="request" type="com.action.Manager" validate="true"> <forward name="managerLoginok" path="/main.jsp" /> <forward name="error" path="/error.jsp" /> </action> <action name="ParameterForm" path="/parameter" scope="request" type="com.action.Parameter" validate="true"> <forward name="error" path="/error.jsp" /> <forward name="parametermodify" path="/parameter_ok.jsp?para=2" /> <forward name="parametermodifyQuery" path="/parameter_modify.jsp" /> </action> </action-mappings> <message-resources parameter="com.wgh.struts.ApplicationResources" /> </struts-config> ```
myeclipse连接mysql出现异常
<%@ 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>查询条件提交页面</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> 请选择查询条件<hr width="100%" size="3"> <form action="find_stu_3.jsp" method="post"> Sex: male<input type="radio" value="m" name="sex" checked="checked" > female<input type="radio" value="f" name="sex" ><br><br> 体重范围:<p>&nbsp;&nbsp;&nbsp;&nbsp; 最小:<input type="text" value="0" name="w1" ><br><br> &nbsp;&nbsp;&nbsp;&nbsp; 最大:<input type="text" value="100" name="w2" ><p> 身高范围:<p>&nbsp;&nbsp;&nbsp;&nbsp; 最小:<input type="text" value="140" name="h1" ><br><br> &nbsp;&nbsp;&nbsp;&nbsp; 最大:<input type="text" value="200" name="h2" ><br><br> <input type="submit" value="提交"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" value="取消"> </p> </form> </body> </html> <%@ page language="text/html" import="java.sql.*" 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>由提交页面获取查询条件并实现查询的页面</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> <center> <% String driverName="com.mysql.jdbc.Driver"; String userName="root"; String userPwd="123456"; String dbName="student"; String url1="jdbc:mysql://localhost:3306/"+dbName; String url2="?user="+userName+"&password="+userPwd; String url3="&useUnicode=true&characterEncoding=UTF-8"; String url=url1+url2+url3; Class.forName(driverName); Connection conn=DriverManager.getConnection(url); request.setCharacterEncoding("UTF-8"); String sex=request.getParameter("sex"); float weight1=Float.parseFloat(request.getParameter("w1")); float weight2=Float.parseFloat(request.getParameter("w2")); float hight1=Float.parseFloat(request.getParameter("h1")); float hight2=Float.parseFloat(request.getParameter("h2")); String sql="select * from stu_info1 where sex=? and weight>=? and weight<=? and hight>=? and hight<=?"; PreparedStatement pstmt=conn.prepareStatement(sql); pstmt.setString(1,sex); pstmt.setFloat(2,weight1); pstmt.setFloat(3,weight2); pstmt.setFloat(4,hight1); pstmt.setFloat(5,hight2); ResultSet rs=pstmt.executeQuery(); rs.last(); %> <table border="2" bgcolor="ccceee" width="650"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>id</td><td>name</td> <td>sex</td><td>age</td><td>weight</td><td>height</td> </tr> <%rs.beforeFirst(); while(rs.next()){ %><tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getInt("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getInt("age") %></td> <td><%=rs.getFloat("weight") %></td> <td><%=rs.getFloat("hight") %></td> </tr> <%} %> </table> </center> <%if(rs!=null){rs.close();} if(pstmt!=null){pstmt.close();} if(conn!=null){conn.close();} %> </body> </html> description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: /find_stu_3.jsp(1,1) Page directive: invalid language attribute 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:102) org.apache.jasper.compiler.PageInfo.setLanguage(PageInfo.java:374) org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:117) org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590) 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.Validator.validate(Validator.java:1700) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178) 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: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) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
JSP对数据库进行信息添加及关键字查询出现错误,怎么解决
org.apache.jasper.JasperException: An exception occurred processing JSP page /emp_list.jsp at line 18 15: if(keyWord==null){ 16: keyWord=""; 17: } 18: List<Emp> all=DAOFactory.getIEmpDAOInstance().findAll(keyWord); 19: Iterator<Emp> iter=all.iterator(); 20: %> 21: <center> 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:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845) org.apache.jsp.emp_005flist_jsp._jspService(emp_005flist_jsp.java:141) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:525) com.mysql.jdbc.Util.handleNewInstance(Util.java:409) com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118) com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343) com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308) com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122) com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774) com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:525) com.mysql.jdbc.Util.handleNewInstance(Util.java:409) com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375) com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289) java.sql.DriverManager.getConnection(DriverManager.java:579) java.sql.DriverManager.getConnection(DriverManager.java:221) com.wgh.dbc.DatabaseConnection.<init>(DatabaseConnection.java:13) com.wgh.dao.proxy.EmpDAOProxy.<init>(EmpDAOProxy.java:13) com.wgh.factory.DAOFactory.getIEmpDAOInstance(DAOFactory.java:7) org.apache.jsp.emp_005flist_jsp._jspService(emp_005flist_jsp.java:82) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause java.net.UnknownHostException: locahost java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) java.net.InetAddress.getAllByName0(InetAddress.java:1211) java.net.InetAddress.getAllByName(InetAddress.java:1127) java.net.InetAddress.getAllByName(InetAddress.java:1063) com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:246) com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292) com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308) com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122) com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774) com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:525) com.mysql.jdbc.Util.handleNewInstance(Util.java:409) com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375) com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289) java.sql.DriverManager.getConnection(DriverManager.java:579) java.sql.DriverManager.getConnection(DriverManager.java:221) com.wgh.dbc.DatabaseConnection.<init>(DatabaseConnection.java:13) com.wgh.dao.proxy.EmpDAOProxy.<init>(EmpDAOProxy.java:13) com.wgh.factory.DAOFactory.getIEmpDAOInstance(DAOFactory.java:7) org.apache.jsp.emp_005flist_jsp._jspService(emp_005flist_jsp.java:82) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.57 logs.
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
立即提问