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.

1个回答

可能是主机名配置问题:
/etc/hosts中配置对应本机IP,否则java.net.InetAddress.getLocalHost会抛出java.Net.UnknownHostException异常。
查一下目标服务器的hosts文件。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
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.
jsp中连接mysql数据库失败
问题出在Class.forName("com.mysql.jdbc.Driver") 错误提示:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver。 但是我已经在工程下添加了驱动包了,也在build path中导入了,而且在java文件测试时 一切都是正常的,但是放到JSP页面里出了问题:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
用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操作mysql数据库的问题
我是想做一个什么事呢:就是在jsp里用statement的executeQuery(string)来向数据库增加数据,数据库为hanshuangwu,表为infor,其中只有两个属性:id、name。执行下面的代码后,显示在“****”标记的代码处有“Unknown column 'idString' in 'field list' ”错误,菜鸟求解,请高手不吝赐教啊^_^ <%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%> <%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030" import="java.sql.*"%> <% request.setCharacterEncoding("gb2312"); %> <!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=GB18030"> <title>连接数据库</title> </head> <body> <H2>连接数据库库</H2> <% int idString=1; String nameString="呵呵"; String driverClass="com.mysql.jdbc.Driver"; String url="jdbc:mysql://localhost:3306/hanshuangwu"; String username="root"; String password="161006"; try{ Class.forName(driverClass); }catch(ClassNotFoundException e) { System.out.println("加载数据库驱动程序时异常(不就是失败嘛!)内容如下:"); e.printStackTrace(); } Connection con=DriverManager.getConnection(url, username, password); Statement stmt=con.createStatement(); ****int rtn=stmt.executeUpdate("insert into infor(id,name) values(idString,nameString)");**** ResultSet rs = stmt.executeQuery("select * from infor "); rs.next(); while(rs.next() ){ out.println("id:"+rs.getInt(1)+"name:"+rs.getString(2)); } rs.close(); stmt.close(); con.close(); %> </body> </html>
jsp连接 mysql 更新语法错误,大家帮我看看,谢谢~
update test set check='1' where memName ='lmy'
jdbc 连接Mysql 遇到问题
错误信息: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1895) at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:496) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:997) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1699) at com.mysql.jdbc.Connection.<init>(Connection.java:408) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:221) at com.mingrisoft.DBConnection.getConnToMySql(DBConnection.java:63) at com.mingrisoft.DBConnection.getConn(DBConnection.java:33) at com.mingrisoft.Login.LoginCheck(Login.java:19) at org.apache.jsp.admin.login_jsp._jspService(login_jsp.java:125) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at 连接信息:MySQLURL=jdbc:mysql://127.0.0.1:3306/webdb MySQLName=root MySQLPassword=password ===================已经试过的方法================ 1、mysql数据库 等待时间调大 wait_timeout=31536000 interactive_timeout=31536000 2、重装mysql 3、驱动包版本没问题,已经换过多个版本 4、客户端和cmd都可以连接
jsp连接mysql数据库将表中信息显示到页面中出现以下错误怎么解决
HTTP Status 500 - Unable to compile class for JSP: type Exception report message Unable to compile class for JSP: description The server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 1 in the generated java file The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files An error occurred at line: 1 in the generated java file The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files An error occurred at line: 14 in the generated java file Only a type can be imported. javassist.bytecode.stackmap.TypeData.ClassName resolves to a package Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs. Apache Tomcat/7.0.30
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]
出现内部错误 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的java文件。
各位好,我实在是菜鸟,在网上找个JAVA文件,连接mysql数据库,经过测试,已经成功,现在用JSP页面来调用,就是不通过,真心请各位指点,急急急,下面把JAVA文件和JSP页面发出来,小弟谢过! JAVA文件 import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Connection; import java.sql.Statement; public class DB { public static void main(String[] args) throws Exception { Connection conn = null; String sql; // MySQL的JDBC URL编写方式:jdbc:mysql://主机名称:连接端口/数据库的名称?参数=值 // 避免中文乱码要指定useUnicode和characterEncoding // 执行数据库操作之前要在数据库管理系统上创建一个数据库,名字自己定, // 下面语句之前就要先创建javademo数据库 String url = "jdbc:mysql://localhost:3306/数据库名字?" + "user=数据库用户名&password=数据库密码&useUnicode=true&characterEncoding=UTF8"; try { // 之所以要使用下面这条语句,是因为要使用MySQL的驱动,所以我们要把它驱动起来, // 可以通过Class.forName把它加载进去,也可以通过初始化来驱动起来,下面三种形式都可以 Class.forName("com.mysql.jdbc.Driver");// 动态加载mysql驱动 // or: // com.mysql.jdbc.Driver driver = new com.mysql.jdbc.Driver(); // or: // new com.mysql.jdbc.Driver(); System.out.println("成功加载MySQL驱动程序"); // 一个Connection代表一个数据库连接 conn = DriverManager.getConnection(url); // Statement里面带有很多方法,比如executeUpdate可以实现插入,更新和删除等 Statement stmt = conn.createStatement(); sql = "create table student(NO char(20),name varchar(20),primary key(NO))"; int result = stmt.executeUpdate(sql);// executeUpdate语句会返回一个受影响的行数,如果返回-1就没有成功 if (result != -1) { System.out.println("创建数据表成功"); sql = "insert into student(NO,name) values('2012001','陶伟基')"; result = stmt.executeUpdate(sql); sql = "insert into student(NO,name) values('2012002','周小俊')"; result = stmt.executeUpdate(sql); sql = "select * from student"; ResultSet rs = stmt.executeQuery(sql);// executeQuery会返回结果的集合,否则返回空值 System.out.println("学号\t姓名"); while (rs.next()) { System.out .println(rs.getString(1) + "\t" + rs.getString(2));// 入如果返回的是int类型可以用getInt() } } } catch (SQLException e) { System.out.println("MySQL操作错误"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } } } JSP页面 <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.*"%> <%@ page import="org.cmcc.databaseconnection.*"%> <% request.setCharacterEncoding("utf-8"); %> <% DB conn=new DB(); Statement stmt = conn.createStatement(); String str1 = "select * from yh"; ResultSet result=stmt.executeQuery(str1); if(result.next()) { %> <%=result.getString(2)%>; <% } else { %> <script language="javascript"> alert("XX"); history.back(); </script> <% } %>
用jsp写的表单用户登录页面,访问mysql数据库时候 出错 ,如下图
在处理登录的时候为什么有时候出现500错误,有时候又出现找不到数据库连接,我用得mysql数据库,驱动程序也添加了的,求大神指教一下啊! ![登录页面![登录处理错误页面![注册页面![注册处理错误页面](https://img-ask.csdn.net/upload/201505/20/1432088914_125244.jpg)](https://img-ask.csdn.net/upload/201505/20/1432088899_672024.jpg)](https://img-ask.csdn.net/upload/201505/20/1432088869_715910.jpg)](https://img-ask.csdn.net/upload/201505/20/1432088840_415605.jpg)
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
JSP+servlet实现网页数据插入mysql问题求解
本意是将网页上表格数据插入到mysql的表中 数据获取和类的构造 L_datainsert.java package a; import java.io.IOException; import java.util.Date; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public abstract class L_datainsert implements javax.servlet.Servlet { public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{ response.setContentType("text/html"); request.setCharacterEncoding("UTF-8"); String[] thi=request.getParameterValues("thi"); String[] the=request.getParameterValues("the"); String[] fl=request.getParameterValues("fl"); String[] chu=request.getParameterValues("chu"); String[] hh=request.getParameterValues("hh"); for(int n=0;n<10;n++){ Hs hs = new Hs(); hs.setThi(Double.parseDouble(thi[n])); hs.setThe(Double.parseDouble(the[n])); hs.setFl(Double.parseDouble(fl[n])); hs.setChu(Double.parseDouble(chu[n])); hs.setHh(Double.parseDouble(hh[n])); Hsinsert db = new Hsinsert(); boolean canLogin = db.addHs(hs);} } } class Hs { private double thi; private double the; private double fl; private double chu; private double hh; public Hs(double i, double e, double l,double u, double h) { thi = i; the = e; fl = l; chu = u; hh = h; } public Hs() { } public void setThi(double thi){ this.thi = thi; } public double getThi(){ return thi; } public void setThe(double the){ this.the = the; } public double getThe(){ return the; } public void setFl(double fl){ this.fl = fl; } public double getFl(){ return fl; } public void setChu(double chu){ this.chu = chu; } public double getChu(){ return chu; } public void setHh(double hh){ this.hh = hh; } public double getHh(){ return hh; } } 插入方法实现:Hsinsert.java package a; import java.sql.*; public class Hsinsert { boolean bInited = false; //加载驱动 public void initJDBC() throws ClassNotFoundException { //加载MYSQL JDBC驱动程序 Class.forName("com.mysql.jdbc.Driver"); bInited = true; System.out.println("Success loading Mysql Driver!"); } public Connection getConnection() throws ClassNotFoundException, SQLException{ if(!bInited){ initJDBC(); } //连接URL为 jdbc:mysql//服务器地址/数据库名 //后面的2个参数分别是登陆用户名和密码 Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/login?characterEncoding=utf8&useSSL=true","root",""); return conn; } public boolean addHs(Hs hs){ boolean returnValue = false; try{ Class.forName("com.mysql.jdbc.Driver");//加载数据库驱动,注册到驱动管理器 Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/login?characterEncoding=utf8&useSSL=true","root",""); //创建connection连接, String sql="insert into hs(thi,the,fl,chu,hh) values(?,?,?,?,?)"; //添加图书信息的sql语句 PreparedStatement ps=conn.prepareStatement(sql); //获取PreparedStatement ps.setDouble(2,hs.getThi());//对sql语句中的第1个参数赋值 ps.setDouble(3,hs.getThe());//对sql语句中的第2个参数赋值 ps.setDouble(4,hs.getFl());//对sql语句中的第3个参数赋值 ps.setDouble(5,hs.getChu());//对sql语句中的第4个参数赋值 ps.setDouble(6,hs.getHh()); int row=ps.executeUpdate();//执行更新操作,返回所影响的行数 if(row>0){ returnValue = true; } ps.close(); conn.close(); }catch (ClassNotFoundException e) { e.printStackTrace(); }catch (SQLException e) { e.printStackTrace(); } return returnValue; } } 但是运行没办法实现 弹出![图片说明](https://img-ask.csdn.net/upload/201706/01/1496308529_290964.png) 是因为我没有设置好xml文件吗 还是别的原因?我的xml文件内容如下:![图片说明](https://img-ask.csdn.net/upload/201706/01/1496312692_144002.png) 工程内容截图为:![图片说明](https://img-ask.csdn.net/upload/201706/01/1496312785_296623.png) 我重新配置了xml文件:![图片说明](https://img-ask.csdn.net/upload/201706/02/1496367553_524699.png) 但还是没好,运行错误为![图片说明](https://img-ask.csdn.net/upload/201706/02/1496367922_913258.png) ![图片说明](https://img-ask.csdn.net/upload/201706/02/1496367937_625333.png)
jsp连接数据库 jsp不能解析类
错误码 HTTP Status 500 – Internal Server Error Type Exception Report Message Unable to compile class for JSP: Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [14] in the generated java file: [D:\Tomcat\work\Catalina\localhost\UI\org\apache\jsp\WebRoot\show_002drecord_jsp.java] Only a type can be imported. com.mysql.jdbc.Driver resolves to a package Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:461) org.apache.jasper.compiler.Compiler.compile(Compiler.java:392) org.apache.jasper.compiler.Compiler.compile(Compiler.java:362) org.apache.jasper.compiler.Compiler.compile(Compiler.java:346) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) 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
JSP连接数据库插入数据相关问题?
``` <%@ page contentType="text/html; charset=utf-8" %> <%@ page language="java" %> <%@ page import="com.mysql.jdbc.Driver" %> <%@ page import="java.sql.*" %> <html> <head> </head> <% //request.setCharacterEncoding("utf-8"); //String text = request.getParameter("text"); //加载驱动程序 String driverName="com.mysql.jdbc.Driver"; //数据库信息 String USER = "root"; //密码 String PASS = "sq123456"; String DB_URL="jdbc:mysql://localhost/official_website"; Connection conn = null; Statement stmt = null; out.print("连接中......"); try{ // 注册 JDBC 驱动 Class.forName("com.mysql.jdbc.Driver"); out.print("连接成功......"); // 打开链接 conn = DriverManager.getConnection(DB_URL,USER,PASS); out.print("打开连接......"); stmt = conn.createStatement(); String sql; sql = "INSERT INTO test_table (context) VALUES('I'm a saver!testing!testing!')"; out.print("读取SQL语句中......."); stmt.executeUpdate(sql); out.print("执行完成......."); out.print("Success!"); out.print(sql); // 完成后关闭 stmt.close(); conn.close(); }catch(SQLException se){ // 处理 JDBC 错误 se.printStackTrace(); }catch(Exception e){ // 处理 Class.forName 错误 e.printStackTrace(); }finally{ // 关闭资源 try{ if(stmt!=null) stmt.close(); }catch(SQLException se2){ }// 什么都不做 try{ if(conn!=null) conn.close(); }catch(SQLException se){ se.printStackTrace(); } } %> <body> </body> </html> ``` 这个段代码的stmt.executeUpdate(sql);这个段语句不执行也不报错到这就停了。这是为什么?
JSP文件因为导包不能正常编译
编写了一个JSP页面,通过一个类与MYSQL连接。但是出现了下面的错误: 严重: Servlet.service() for servlet [jsp] in context with path [/shop] threw exception [Unable to compile class for JSP] with root cause 而且,没有导包的jsp代码正常运行。一旦导了包,就出现这样的错误。
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> ```
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)
jsp页面有错误,如何显示详细错误信息?
就一个页面,代码非常的简单。 ``` <%@ page language="java" pageEncoding="UTF-8" %> <%@page import="java.sql.DriverManager" %> <%@page import="java.sql.Connection" %> <html> <head> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title> test</title></head> <body> <% try{ Class.forName("com.mysql.jdbc.Driver");//注册驱动 String url="jdbc:mysql://127.0.0.1:3306/javaweb"; String username="javaweb"; String password="javaweb"; Connection conn=DriverManager.getConnection(url,username,password); if(conn!=null){ out.println("数据库连接成功!!!"); }else{ System.out.println("数据库连接失败"); } }catch(ClassNotFoundException e){ e.printStackTrace(); } %> </body> </html> ``` 运行上面的代码是没问题的。但是当我把password 修改成为错误的,如修改为javaweb1 则页面提示如下 ![图片说明](https://img-ask.csdn.net/upload/201810/07/1538903423_315370.png) 如何调整为可以显示具体错误的页面?也就是能在页面上抛出异常?
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
这30个CSS选择器,你必须熟记(上)
关注前端达人,与你共同进步CSS的魅力就是让我们前端工程师像设计师一样进行网页的设计,我们能轻而易举的改变颜色、布局、制作出漂亮的影音效果等等,我们只需要改几行代码,不需...
国产开源API网关项目进入Apache孵化器:APISIX
点击蓝色“程序猿DD”关注我回复“资源”获取独家整理的学习资料!近日,又有一个开源项目加入了这个Java开源界大名鼎鼎的Apache基金会,开始进行孵化器。项目名称:AP...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
编写Spring MVC控制器的14个技巧
本期目录 1.使用@Controller构造型 2.实现控制器接口 3.扩展AbstractController类 4.为处理程序方法指定URL映射 5.为处理程序方法指定HTTP请求方法 6.将请求参数映射到处理程序方法 7.返回模型和视图 8.将对象放入模型 9.处理程序方法中的重定向 10.处理表格提交和表格验证 11.处理文件上传 12.在控制器中自动装配业务类 ...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
求小姐姐抠图竟遭白眼?痛定思痛,我决定用 Python 自力更生!
点击蓝色“Python空间”关注我丫加个“星标”,每天一起快乐的学习大家好,我是 Rocky0429,一个刚恰完午饭,正在用刷网页浪费生命的蒟蒻...一堆堆无聊八卦信息的网页内容慢慢使我的双眼模糊,一个哈欠打出了三斤老泪,就在此时我看到了一张图片:是谁!是谁把我女朋友的照片放出来的!awsl!太好看了叭...等等,那个背景上的一堆鬼画符是什么鬼?!真是看不下去!叔叔婶婶能忍,隔壁老王的三姨妈的四表...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问