数据库MYSQL连接成功,可是遍历next()结果不是我想要呀!!!

事件监听中要检验JTextField的内容是否与数据库中一致,一致则登录成功,否则登录失败,但是现在无论JTextField的内容如何,都是输出登录失败,求大神解救啊。。。

import java.sql.*;

import javax.swing.JOptionPane;

public class MysqlJdbc {
public User user= new User();

    public void Login(User user){

    String url=null;
    Connection con=null;
    Statement stmt=null;
    ResultSet rs=null;

   // String qu="SELECT * FROM login where UserName='"+user+"';";

    try{
   String a=user.getUserName();
   String b=user.getPassword();
    /*
     * 通过mySQL专用引擎获得连接对象
     * locahost为IP地址,3306为端口号,DatabaseName为安装的一个数据库服务名
    */
    url="jdbc:mysql:localhost:3306;DatabaseName=hou";
    Class.forName("com.mysql.jdbc.Driver");
    System.out.println("连接数据库成功!");
    con =DriverManager.getConnection( "jdbc:mysql://localhost:3306/hou","root","123456");

    stmt=con.createStatement();
    String query="select UserName,Password from login where UserName='"+a+"' and Password='"+b+"';";
                                   //向数据库提交查询语句,获得一个被rs引用的结果集
    rs=stmt.executeQuery(query);
                                   //对结果集进行遍历,显示其内容

    if (rs.next()) {
        JOptionPane.showMessageDialog(null,"登录成功" );          
    }
    else{
       JOptionPane.showMessageDialog(null, "登录失败"); 
    }   


    }
    catch (Exception e) {
        System.out.print("连接数据库失败!");
        e.printStackTrace();
    }
    finally{

        try{
        if(rs!=null){
            rs.close();}
        if(stmt!=null){
            stmt.close();}
        if(con!=null){
            con.close();}
        }
        catch(SQLException e){}
    }
    }

}

btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String UserName=textUserName.getText();

String Password=passwordField.getText();
User user=new User();
user.setUserName(UserName);
user.setPassword(Password);

                          MysqlJdbc mysqlJdbc=new MysqlJdbc();
                          mysqlJdbc.Login(user);
                            }
                            }

5个回答

用debug 调试撒、 打断点,查看一下 你的 query 值,然后扔到mysql中去跑看看能不能查询到值

把SQL语言打印出来,在数据库里执行一下看看;

先看你的SQL语句执行结果是什么 再来分析原因

那你想要的是什么?,,,

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java查询数据库中的数据会输出,输出的不是我的数据????
# ```数据封装在build,builds中 可是输出的不是数据库中的数据而是 ![图片说明](https://img-ask.csdn.net/upload/202004/02/1585822586_24417.jpg) # DormBuildDaoImpl.java package zj.shizhan.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import zj.shizhan.bean.DormBuild; import zj.shizhan.util.ConnectionFactory; public class DormBuildDaoImpl implements DormBuildDao { @Override public DormBuild findByName(String dormBuildName) { //获取连接(数据库地址 用户名 密码) Connection connection = ConnectionFactory.getConnection(); try { String sql = "select * from dormbuild where dormBuildName = ? "; //执行SQL语句 获取集装箱 或者说是 车 PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, dormBuildName); ResultSet rs = preparedStatement .executeQuery(); //因为查询出来的信息包括表头信息,所以指针下移一行,看是否有查询出的数据 //如有数据,就进入循环体封装该行数据 while (rs.next()) { DormBuild build = new DormBuild(); build.setDormBuildId(rs.getInt("dormBuildId")); build.setDormBuildName(rs.getString("dormBuildName")); build.setDetail(rs.getString("detail")); return build; } } catch (SQLException e) { e.printStackTrace(); } return null; } @Override public void save(DormBuild build) { //获取连接(数据库地址 用户名 密码) Connection connection = ConnectionFactory.getConnection(); try { String sql = "INSERT INTO dormbuild(dormBuildName,detail)VALUES(?,?)"; //执行SQL语句 获取集装箱 或者说是 车 PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, build.getDormBuildName()); preparedStatement.setString(2, build.getDetail()); preparedStatement .executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } @Override public List<DormBuild> find() { //获取连接(数据库地址 用户名 密码) Connection connection = ConnectionFactory.getConnection(); try { String sql = "select * from dormbuild "; //执行SQL语句 获取集装箱 或者说是 车 PreparedStatement preparedStatement = connection.prepareStatement(sql); ResultSet rs = preparedStatement .executeQuery(); //因为查询出来的信息包括表头信息,所以指针下移一行,看是否有查询出的数据 //如有数据,就进入循环体封装该行数据 List<DormBuild> builds = new ArrayList<DormBuild>(); while (rs.next()) { DormBuild build = new DormBuild(); build.setDormBuildId(rs.getInt("dormBuildId")); build.setDormBuildName(rs.getString("dormBuildName")); build.setDetail(rs.getString("detail")); builds.add(build); } return builds; } catch (SQLException e) { e.printStackTrace(); } return null; } @Override public DormBuild findById(Integer dormBuildId) { //获取连接(数据库地址 用户名 密码) Connection connection = ConnectionFactory.getConnection(); try { String sql = "select * from dormbuild where dormBuildId = ? "; //执行SQL语句 获取集装箱 或者说是 车 PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setInt(1, dormBuildId); ResultSet rs = preparedStatement .executeQuery(); //因为查询出来的信息包括表头信息,所以指针下移一行,看是否有查询出的数据 //如有数据,就进入循环体封装该行数据 while (rs.next()) { DormBuild build = new DormBuild(); build.setDormBuildId(rs.getInt("dormBuildId")); build.setDormBuildName(rs.getString("dormBuildName")); build.setDetail(rs.getString("detail")); return build; } } catch (SQLException e) { e.printStackTrace(); } return null; } @Override public void update(DormBuild build ) { //获取连接(数据库地址 用户名 密码) Connection connection = ConnectionFactory.getConnection(); try { String sql = "UPDATE dormbuild SET dormBuildName = ?,detail = ? WHERE dormBuildId = ?"; //执行SQL语句 获取集装箱 或者说是 车 PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, build.getDormBuildName()); preparedStatement.setString(2, build.getDetail()); preparedStatement.setInt(3, build.getDormBuildId()); //执行更新 preparedStatement .executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } } ``` # DormBuildServlet.java ``` package zj.shizhan.servlet; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import zj.shizhan.bean.DormBuild; import zj.shizhan.service.DormBuildService; import zj.shizhan.service.DormBuildServiceImpl; /** * Servlet implementation class DormBuildServlet */ @WebServlet("/dormBuild.action") public class DormBuildServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public DormBuildServlet() { super(); } /** * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response) */ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); String action = request.getParameter("action"); //通过request.getParameter("id")方式获取的值都是String类型的 String dormBuildId = request.getParameter("dormBuildId"); System.out.println("action:"+action); DormBuildService dormBuildService = new DormBuildServiceImpl(); if(action !=null & action.equals("list")) { List<DormBuild> builds = new ArrayList<DormBuild>(); if( dormBuildId== null || dormBuildId.equals("")) { //查询所有宿舍楼信息,跳转到宿舍楼列表页 builds = dormBuildService.find(); }else if(dormBuildId != null && !dormBuildId.equals("")) { //点击查询按钮搜索某一栋宿舍楼的信息 DormBuild build = dormBuildService.findById(Integer.parseInt(dormBuildId)); builds.add(build); System.out.println("build:"+build); } //查询所有宿舍楼。在select中遍历 List<DormBuild> buildSelects = dormBuildService.find(); request.setAttribute("buildSelects", buildSelects); request.setAttribute("dormBuildId", dormBuildId); System.out.println("builds:"+builds); request.setAttribute("builds", builds); request.getRequestDispatcher("BuildList.jsp").forward(request, response); }else if (action !=null & "preAdd".equals(action)) { //表示跳转到宿舍楼添加页面 request.getRequestDispatcher("AddOrAlterBuild.jsp").forward(request, response); }else if (action !=null & "save".equals(action)) { //保存数据 String n = request.getParameter("dormBuildName"); String dormBuildName = new String(n.getBytes("ISO-8859-1"), "utf-8"); String m = request.getParameter("detail"); String detail = new String(m.getBytes("ISO-8859-1"), "utf-8"); System.out.println("dormBuildName:"+dormBuildName+"detail:"+detail+"id:"+dormBuildId); //判断宿舍楼名字是否已存在 DormBuild dormBuild = dormBuildService.findByName(dormBuildName); System.out.println("dormBuildName:"+dormBuildName); System.out.println("id2:"+dormBuildId); if(dormBuildId !=null && !"".equals(dormBuildId)) { System.out.println("id3:"+dormBuildId); //修改 if (dormBuild != null && !dormBuild.getDormBuildId().equals(Integer.parseInt(dormBuildId))) { request.setAttribute("error", "该宿舍楼已存在"); //格局宿舍楼id,查询宿舍楼 DormBuild build = dormBuildService.findById(Integer.parseInt(dormBuildId)); //保存宿舍楼信息,到前端页面展示 request.setAttribute("build", build); request.getRequestDispatcher("AddOrAlterBuild.jsp").forward(request, response); }else { dormBuild = dormBuildService.findById(Integer.parseInt(dormBuildId)); dormBuild.setDormBuildName(dormBuildName); dormBuild.setDetail(detail); dormBuildService.update(dormBuild); //更新完成后,跳转到宿舍楼管理列表页,查询所有宿舍楼 List<DormBuild> builds = dormBuildService.find(); request.setAttribute("builds", builds); request.getRequestDispatcher("BuildList.jsp").forward(request, response); } }else { //保存 System.out.println("id4:"+dormBuildId); if (dormBuild != null) { //该宿舍楼已存在 request.setAttribute("error", "该宿舍楼已存在"); request.getRequestDispatcher("AddOrAlterBuild.jsp").forward(request, response); }else { //该宿舍楼已不存在 DormBuild build = new DormBuild(); build.setDormBuildName(dormBuildName); build.setDetail(detail); dormBuildService.save(build); List<DormBuild> builds = dormBuildService.find(); request.setAttribute("builds", builds); request.getRequestDispatcher("BuildList.jsp").forward(request, response); } } }else if (action !=null & "preUpdate".equals(action)) { //格局宿舍楼id,查询宿舍楼 DormBuild build = dormBuildService.findById(Integer.parseInt(dormBuildId)); System.out.println("id1:"+dormBuildId); //保存宿舍楼信息,到前端页面展示 request.setAttribute("build", build); //表示跳转到宿舍楼修改页面 request.getRequestDispatcher("AddOrAlterBuild.jsp").forward(request, response); } } } ``` # DormBuild.java ``` package zj.shizhan.bean; public class DormBuild { private Integer dormBuildId; private String dormBuildName; private String detail; public DormBuild() { super(); } public DormBuild(Integer dormBuildId,String dormBuildName, String detail) { super(); this.dormBuildId = dormBuildId; this.dormBuildName = dormBuildName; this.detail = detail; } public String getDormBuildName() { return dormBuildName; } public void setDormBuildName(String dormBuildName) { this.dormBuildName = dormBuildName; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public Integer getDormBuildId() { return dormBuildId; } public void setDormBuildId(Integer dormBuildId) { this.dormBuildId = dormBuildId; } } ```
ecplise连接数据库mysql8.0出错
ecplise2019-03连接数据库mysql8.0出错,我的ecplise连接SQL是好的 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class a1 { public static void main(String []args) { Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; // The newInstance() call is a work around for some // broken Java implementations try { Class.forName("com.mysql.jdbc.Driver"); System.out.println("加载成功"); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC","root","qing980104"); System.out.println("连接成功"); } } catch (SQLException ex) { // handle any errors System.out.println("连接失败"); } } } 结果显示 Exception in thread "main" java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at experiment1.a1.main(a1.java:7) 我把代码换成运行成功的SQL连接代码,然后改了下 import java.sql.*; public class a1 { public static void main(String[] args) throws SQLException, ClassNotFoundException { // TODO Auto-generated method stub Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn= DriverManager.getConnection(jdbc:mysql://127.0.0.1:3306/shop?serverTimezone=GMT%2B8","root","qing980104"); Statement stm=conn.createStatement(); ResultSet re=stm.executeQuery("select * from book"); while(re.next()) { System.out.println("书名:"+re.getString(1)+"书号:"+re.getString(2)+"价格:"+re.getString(3)); } re.close(); stm.close(); conn.close(); } } 结果显示 Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251) at mysql.connector.java@8.0.15/com.mysql.cj.jdbc.admin.TimezoneDump.main(TimezoneDump.java:70) 我以前写的java课设中连接数据库也是显示上面(using password: NO)这个结果 网上有说是MySQL8.0用了强密码的缘故,我重下装了改成旧方式,但还是不行,我又重装了n次,结果现在只能是旧方式,无法改成强密码方式。而且程序还是不行。求大佬解答
mysql 连接数据库报 找不到驱动程序
package com.wfb; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class DBUtil { private static final String URL = "jdbc.mysql://127.0.0.1:3306/imooc"; private static final String USER = "root"; private static final String PASSWORD = "root"; public static void main(String[] args) throws Exception{ //加载驱动 Class.forName("com.mysql.jdbc.Driver"); //获得数据库的链接 Connection conn = DriverManager.getConnection(URL, USER, PASSWORD); //通过数据库的连接操作数据库,实现增删改查 Statement sta = conn.createStatement(); ResultSet rs = sta.executeQuery("select name from imooc_goddess"); while(rs.next()){ System.out.println(rs.getString("name")); } } } 这是报的异常 Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc.mysql://127.0.0.1:3306/imooc at java.sql.DriverManager.getConnection(DriverManager.java:602) at java.sql.DriverManager.getConnection(DriverManager.java:185) at com.wfb.DBUtil.main(DBUtil.java:22) mysql-connector-java-5.1.18-bin.jar已经附加成功了 之前的web 项目可以 现在单独的练习 一直出现问题 数据库 以及表名都没有错误 将驱动加入了:C:\Program Files\Java\jre7\lib\ext中,仍然报错 求大神解答
scrapy存到mysql查询无数据
## 1. 问题描述 尝试使用scrapy框架爬取网站,将爬取的数据存储到mysql数据库,执行完毕之后没有报错,但是我查询数据时,显示没有数据 (代码框架参考使用该博主代码尝试运行: https://www.cnblogs.com/fromlantianwei/p/10607956.html) ## 2. 部分截图 1. scrapy项目: ![图片说明](https://img-ask.csdn.net/upload/202003/04/1583310103_446281.png) 数据库创建: ![图片说明](https://img-ask.csdn.net/upload/202003/04/1583310345_774265.png) ##3. 相关代码 scrapy框架代码: (1)tencent爬虫文件 ``` # -*- coding: utf-8 -*- import scrapy from urllib import parse import re from copy import deepcopy from ScrapyPro3.items import ScrapyPro3Item class tencentSpider(scrapy.Spider): name = 'tencent' allowed_domains = [] start_urls = [ 'http://tieba.baidu.com/mo/q----,sz@320_240-1-3---2/m?kw=%E6%A1%82%E6%9E%97%E7%94%B5%E5%AD%90%E7%A7%91%E6%8A%80%E5%A4%A7%E5%AD%A6%E5%8C%97%E6%B5%B7%E6%A0%A1%E5%8C%BA&pn=26140', ] def parse(self, response): # 总页面 item = ScrapyPro3Item() all_elements = response.xpath(".//div[@class='i']") # print(all_elements) for all_element in all_elements: content = all_element.xpath("./a/text()").extract_first() content = "".join(content.split()) change = re.compile(r'[\d]+.') content = change.sub('', content) item['comment'] = content person = all_element.xpath("./p/text()").extract_first() person = "".join(person.split()) # 去掉点赞数 评论数 change2 = re.compile(r'点[\d]+回[\d]+') person = change2.sub('', person) # 选择日期 change3 = re.compile(r'[\d]?[\d]?-[\d][\d](?=)') date = change3.findall(person) # 如果为今天则选择时间 change4 = re.compile(r'[\d]?[\d]?:[\d][\d](?=)') time = change4.findall(person) person = change3.sub('', person) person = change4.sub('', person) if time == []: item['time'] = date else: item['time'] = time item['name'] = person # 增加密码 活跃 item['is_active'] = '1' item['password'] = '123456' print(item) yield item # 下一页 """next_url = 'http://tieba.baidu.com/mo/q----,sz@320_240-1-3---2/' + parse.unquote( response.xpath(".//div[@class='bc p']/a/@href").extract_first()) print(next_url) yield scrapy.Request( next_url, callback=self.parse, )""" ``` (2)item文件 ``` # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # https://doc.scrapy.org/en/latest/topics/items.html import scrapy class ScrapyPro3Item(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() comment = scrapy.Field() time = scrapy.Field() name = scrapy.Field() password = scrapy.Field() is_active = scrapy.Field() ``` (3)pipelines文件 # -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html """class Scrapypro3Pipeline(object): def process_item(self, item, spider): return item""" import pymysql from twisted.enterprise import adbapi class Scrapypro3Pipeline(object): def __init__(self, dbpool): self.dbpool = dbpool @classmethod def from_settings(cls, settings): # 函数名固定,会被scrapy调用,直接可用settings的值 """ 数据库建立连接 :param settings: 配置参数 :return: 实例化参数 """ adbparams = dict( host='localhost', db='mu_ke', user='root', password='root', cursorclass=pymysql.cursors.DictCursor # 指定cursor类型 ) # 连接数据池ConnectionPool,使用pymysql或者Mysqldb连接 dbpool = adbapi.ConnectionPool('pymysql', **adbparams) # 返回实例化参数 return cls(dbpool) def process_item(self, item, spider): """ 使用twisted将MySQL插入变成异步执行。通过连接池执行具体的sql操作,返回一个对象 """ query = self.dbpool.runInteraction(self.do_insert, item) # 指定操作方法和操作数据 # 添加异常处理 query.addCallback(self.handle_error) # 处理异常 def do_insert(self, cursor, item): # 对数据库进行插入操作,并不需要commit,twisted会自动commit insert_sql = """ insert into login_person(name,password,is_active,comment,time) VALUES(%s,%s,%s,%s,%s) """ cursor.execute(insert_sql, (item['name'], item['password'], item['is_active'], item['comment'], item['time'])) def handle_error(self, failure): if failure: # 打印错误信息 print(failure)``` ``` (4) settings文件 ``` # -*- coding: utf-8 -*- # Scrapy settings for ScrapyPro3 project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html BOT_NAME = 'ScrapyPro3' SPIDER_MODULES = ['ScrapyPro3.spiders'] NEWSPIDER_MODULE = 'ScrapyPro3.spiders' # Crawl responsibly by identifying yourself (and your website) on the user-agent USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' MYSQL_HOST = 'localhost' MYSQL_DBNAME = 'mu_ke' MYSQL_USER = 'root' MYSQL_PASSWD = 'root' # Obey robots.txt rules ROBOTSTXT_OBEY = False # Configure maximum concurrent requests performed by Scrapy (default: 16) #CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0) # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay # See also autothrottle settings and docs #DOWNLOAD_DELAY = 3 # The download delay setting will honor only one of: #CONCURRENT_REQUESTS_PER_DOMAIN = 16 #CONCURRENT_REQUESTS_PER_IP = 16 # Disable cookies (enabled by default) #COOKIES_ENABLED = False # Disable Telnet Console (enabled by default) #TELNETCONSOLE_ENABLED = False # Override the default request headers: #DEFAULT_REQUEST_HEADERS = { # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', # 'Accept-Language': 'en', #} # Enable or disable spider middlewares # See https://doc.scrapy.org/en/latest/topics/spider-middleware.html #SPIDER_MIDDLEWARES = { # 'ScrapyPro3.middlewares.ScrapyPro3SpiderMiddleware': 543, #} # Enable or disable downloader middlewares # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html #DOWNLOADER_MIDDLEWARES = { # 'ScrapyPro3.middlewares.ScrapyPro3DownloaderMiddleware': 543, #} # Enable or disable extensions # See https://doc.scrapy.org/en/latest/topics/extensions.html #EXTENSIONS = { # 'scrapy.extensions.telnet.TelnetConsole': None, #} # Configure item pipelines # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html ITEM_PIPELINES = { 'ScrapyPro3.pipelines.Scrapypro3Pipeline':200, } # Enable and configure the AutoThrottle extension (disabled by default) # See https://doc.scrapy.org/en/latest/topics/autothrottle.html #AUTOTHROTTLE_ENABLED = True # The initial download delay #AUTOTHROTTLE_START_DELAY = 5 # The maximum download delay to be set in case of high latencies #AUTOTHROTTLE_MAX_DELAY = 60 # The average number of requests Scrapy should be sending in parallel to # each remote server #AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 # Enable showing throttling stats for every response received: #AUTOTHROTTLE_DEBUG = False # Enable and configure HTTP caching (disabled by default) # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings #HTTPCACHE_ENABLED = True #HTTPCACHE_EXPIRATION_SECS = 0 #HTTPCACHE_DIR = 'httpcache' #HTTPCACHE_IGNORE_HTTP_CODES = [] #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' ``` (5)start文件——执行爬虫文件 ``` from scrapy import cmdline cmdline.execute(["scrapy","crawl","tencent"]) ``` 数据库创建代码: ``` create database mu_ke; CREATE TABLE `login_person` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `passsword` varchar(100) DEFAULT NULL, `is_active` varchar(100) DEFAULT NULL, `comment` varchar(100) DEFAULT NULL, `time` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1181 DEFAULT CHARSET=utf8; select count(name) from login_person;#查询结果条数为0 ``` # 运行完代码后查询数据,显示条数为0,这里面有什么问题吗? (1) 执行过程正常 (2)运行 pycharm2019.3 python3.8 mysql8.0(workbench8.0) (3) 数据连接没有
JDBC已成功连接到数据库,但是无法获取数据表的名称?
JDBC成功连接到数据库,我在逐步调式的时候,也看到生成的连接了。 ----- _**应老师的要求,要获取一个数据库中所有的表名称,下面是我写的一个函数,提示没有错误,但最后打印结果,为空。**_ ------- 图片的上一部分是另一个功能,足以证明以成功连接到数据库 ---- 求告知,可能出错的问题,在哪里? 下面是代码 ``` public static List<String> getAllTableNames( String databasename) { List<String> tableNames = new ArrayList<String>(); Connection conn1 = null; try { conn1 = getConnection(); DatabaseMetaData dbmd1 = conn1.getMetaData(); // 表名列表 ResultSet rest = dbmd1.getTables(databasename, null, null, new String[] { "TABLE" }); // 输出 table_name while (rest.next()) { tableNames.add(rest.getString("TABLE_NAME")); } } catch (SQLException e) { e.printStackTrace(); } return tableNames; } ``` ![图片说明](https://img-ask.csdn.net/upload/201911/20/1574255610_398525.png)
java连接MySQL数据库总是提示连接失败,cmd可以读取数据库内容,驱动包也已载入
import java.sql.*; import java.util.*; class Student{ String sno; String name; public Student(String sno, String name) { super(); this.sno = sno; this.name = name; } @Override public String toString() { return "Student [sno=" + sno + ", name=" + name + "]"; } } public class TestJDBC { public static void main(String[] args) { Connection con=null; try{ Class.forName("com.mysql.jdbc.Driver"); String url="jbdc:mysql://localhost:3306/mydb?user=root&password=root&useUnicode=true&characterEncoding=UTF8"; con=DriverManager.getConnection(url); System.out.println("连接成功!"); }catch(ClassNotFoundException e){ System.out.println("载入JDBC驱动类出错"); e.printStackTrace(); return; }catch(SQLException e){ System.out.println("创建数据库连接出错"); e.printStackTrace(); return; } Statement stmt=null; ResultSet rs=null; List<Student> studentList=new ArrayList(); try { String sql="Select * from student"; stmt=con.createStatement(); rs=stmt.executeQuery("mydatabase"); while(rs.next()) { String sno=rs.getString("sno"); String name=rs.getString("name"); Student student=new Student(sno,name); studentList.add(student); } }catch(SQLException e) { System.out.println("查询数据库出错"); e.printStackTrace(); }finally { try { rs.close(); stmt.close(); con.close(); }catch(SQLException e) { System.out.println("关闭资源出错"); e.printStackTrace(); rs=null; stmt=null; con=null; } } for (Student student:studentList){ System.out.println(student); } } } ![图片说明](https://img-ask.csdn.net/upload/201712/01/1512109423_37961.png)
急急急,请教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> <% } %>
Android studio访问mysql闪退,本地测试可以
使用为mysql-connector-java-8.0.16.jar以及mysql8.0.19 在本地测试通过 public class DBUtils { private static String driver = "com.mysql.cj.jdbc.Driver";//MySQL 驱动 private static String url = "jdbc:mysql://192.168.2.146:3306/helper?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true";//MYSQL数据库连接Url private static String user = "wang";//用户名 private static String password = "Imissyou**";//密码 private static Connection getConnection() { Connection conn = null; try { Class.forName(driver); // conn = DriverManager.getConnection(url,user,password); } catch (SQLException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return conn; } public static Map<String, String> login(User user) { HashMap<String, String> map = new HashMap<>(); Connection conn = getConnection(); try { Statement st = conn.createStatement(); String sql= "select * from user where username ='" + user.getUsername() + "' and password ='" + user.getPassword() + "'"; ResultSet res = st.executeQuery(sql); if (res == null) { return null; } else { int cnt = res.getMetaData().getColumnCount(); res.next(); for (int i = 1; i <= cnt; ++i) { String field = res.getMetaData().getColumnName(i); map.put(field, res.getString(field)); } conn.close(); st.close(); res.close(); return map; } } catch (Exception e) { e.printStackTrace(); return null; } } public static void main(String []args){ User user = new User("aaa","123456"); Map<String,String> result= DBUtils.login(user); System.out.println(result); } } 但是在主界面绑定事件,访问数据库时直接闪退并报错 ![图片说明](https://img-ask.csdn.net/upload/202003/15/1584252548_20385.jpg) 主界面代码如下: package com.example.helper; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.StrictMode; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import java.util.Map; public class MainActivity extends AppCompatActivity { private Button register; private Button login_user; private TextView forget_password; private TextView login_visitor; private EditText et_username; private EditText et_password; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //初始化控件 init(); //注册界面跳转 register.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Intent intent = new Intent(MainActivity.this, RegisterActivity.class); startActivity(intent); } }); //登录功能未加载,等待后台数据库完善 login_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String username = et_username.getText().toString(); //获取用户名 String password = et_password.getText().toString(); //获取密码 if(TextUtils.isEmpty(username)){ Toast.makeText(MainActivity.this,"请输入用户名",Toast.LENGTH_SHORT).show(); } else if(TextUtils.isEmpty(password)){ Toast.makeText(MainActivity.this,"请输入密码",Toast.LENGTH_SHORT).show(); } //本地管理员帐号 else if(username.equals("admin")&&password.equals("admin")){ Intent intent = new Intent(MainActivity.this,HomePageActivity.class); startActivity(intent); } //else Toast.makeText(MainActivity.this,"未连接后台数据库",Toast.LENGTH_SHORT).show(); else{ User user = new User(username,password); checkLogin(user); //Toast.makeText(MainActivity.this,"已获取"+username+" "+password,Toast.LENGTH_SHORT).show(); } } }); //首页跳转 login_visitor.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Intent intent = new Intent(MainActivity.this, HomePageActivity.class); startActivity(intent); } }); //找回密码界面跳转 forget_password.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this,ForgetPasswordActivity.class); startActivity(intent); } }); } private void init() { et_username = findViewById(R.id.et_username); et_password = findViewById(R.id.et_password); register = findViewById(R.id.btn_2); login_user = findViewById(R.id.btn_1); login_visitor = findViewById(R.id.login_visitor); forget_password = findViewById(R.id.forget_password); } class DBThread implements Runnable { private User user; private Context context; public void setUser(User user) { this.user = user; } public void setContext(Context context) { this.context = context; } @Override public void run() { Map<String,String> result= DBUtils.login(user); /* if (result != null && result.size() > 0) { Intent intent = new Intent(MainActivity.this,HomePageActivity.class); Toast.makeText(MainActivity.this,"有此帐号",Toast.LENGTH_SHORT).show(); startActivity(intent); } */ } } private void checkLogin(User u) { DBThread dt = new DBThread(); dt.setUser(u); dt.setContext(MainActivity.this); Thread thread = new Thread(dt); thread.start(); } }
新人求解java连接mysql,向数据库添加数据,出错
package test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class test{ public static void main(String[] args)throws Exception { // 加载数据库驱动,注册到驱动管理器 Class.forName("com.mysql.jdbc.Driver"); // 数据库连接字符串 String url = "jdbc:mysql://localhost:3306/test"; // 数据库用户名 String username = "root"; // 数据库密码 String password = "2443243838"; // 创建Connection连接 Connection conn = DriverManager.getConnection(url,username,password); // 判断 数据库连接是否为空 Statement st=conn.createStatement(); Scanner scanner = new Scanner(System.in); System.out.println("1,数据注册\t"); System.out.println("2,登录\t"); System.out.println("请输入你要做的操作:\t"); int n= scanner.nextInt(); if(n==1){ // 输出连接信息 System.out.println("请输入用户名字:"); String username1 = scanner.next(); System.out.println("请输入密码:"); String password1 = scanner.next(); String sql="select * from user where username='"+username1+"'"; ResultSet ra= st.executeQuery(sql); if(ra.next()){ System.out.println("用户已存在"); }else{ sql="insert into user values=('"+username1+"','"+password1+"')"; int i=st.executeUpdate(sql); if(i!=0){ System.out.println("添加成功"); }else{ System.out.println("添加失败"); } } // 关闭数据库连接 }else if(n==2){ }else{ // 输出连接信息 System.out.println("数据库连接失败!"); } } } 1,数据注册 2,登录 请输入你要做的操作: 1 请输入用户名字: 刘备 请输入密码: 123456 Exception in thread "main" 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 '=('刘备','123456')' 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:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725) at test.test.main(test.java:43)
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>
jdbc连接数据库的com.mysql.jdbc.CommunicationsException问题
我使用jdbc连接数据库,连接不上,上网搜了很多,有人说是数据库请求超时问题,也有说是数据库url,账号或者密码配置错误,我检查了都没有问题。还有一点奇怪的是,我用jdbc-odbc桥连接又可以连上数据库,用可视化工具也可以连上,但是用jdbc方式连接不上。。。我现在想着应该是哪里的配置有问题,请教各位大神,看看有谁知道或者遇到过,谢谢大家了 这是我的程序 ``` public static void main(String[] args) { Connection ct = null; Statement sm = null; ResultSet rs = null; try { //1、加载驱动(作用是把需要的驱动程序加入内存) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //2、得到连接(指定连接到哪个数据源) //如果配置数据源选择的是Windows nt验证方式,则不需要用户名和密码 ct = DriverManager.getConnection("jdbc:odbc:MyTest", "root", "root"); //3、创建Statement或者PreparedStatement[区别] //Statement用处是,用于发送sql语句 sm = ct.createStatement(); //4、执行(crud、备份数据库、删除数据库......) //查询,显示所有部门信息 //ResultSet结果集,可以理解成一个表行的结果集 rs = sm.executeQuery("select * from dept"); //因为rs指向结果集的第一行的前一行, //循环取出 while (rs.next()) { int deptno = rs.getInt(1); String dname = rs.getString(2); String loc = rs.getString(3); System.out.println(deptno+" "+dname+" "+loc); } } catch(Exception e) { e.printStackTrace(); } finally { //关闭资源 //关闭顺序是谁后创建谁先关闭 try { //为了程序健壮 if (rs != null) { rs.close(); } if (sm != null) { sm.close(); } if (ct != null) { ct.close(); } } catch (SQLException e) { e.printStackTrace(); } } } ``` 这些是报的异常 ``` com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: Permission denied: recv failed STACKTRACE: java.net.SocketException: Permission denied: recv failed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:152) at java.net.SocketInputStream.read(SocketInputStream.java:122) at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:105) at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:148) at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:176) at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1899) at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:481) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:964) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2544) at com.mysql.jdbc.Connection.<init>(Connection.java:1474) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648) ** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago. at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:552) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:964) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2544) at com.mysql.jdbc.Connection.<init>(Connection.java:1474) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648) ```
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 ![图片说明](https://img-ask.csdn.net/upload/201911/26/1574756378_185801.jpg) ![图片说明](https://img-ask.csdn.net/upload/201911/26/1574756877_818028.jpg) 很急!求救!QAQ
通过eclipse用jdbc连接MySQL时出现问题
求大神帮我解答,运行后出现错误是怎么回事? ![图片说明](https://img-ask.csdn.net/upload/201912/18/1576638062_771148.jpg) ![图片说明](https://img-ask.csdn.net/upload/201912/18/1576637772_468360.jpg) ``` package com.main.JH; import java.sql.*; public class PutinStorage { // JDBC 驱动名及数据库 URL static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost:3306/mysql"; // 数据库的用户名与密码,需要根据自己的设置 static final String USER = "root"; static final String PASS = "123456"; public static void main(String[] args) { Connection conn = null; Statement stmt = null; try{ // 注册 JDBC 驱动 Class.forName("com.mysql.jdbc.Driver"); // 打开链接 System.out.println("连接数据库..."); conn = DriverManager.getConnection(DB_URL,USER,PASS); // 执行查询 System.out.println(" 实例化Statement对象..."); stmt = conn.createStatement(); String sql; sql = "SELECT name,code,score FROM test"; ResultSet rs = stmt.executeQuery(sql); // 展开结果集数据库 while(rs.next()){ // 通过字段检索 String name = rs.getString("name"); String code = rs.getString("code"); int score = rs.getInt("score"); // 输出数据 System.out.print("用户名: " + name); System.out.print(", 密码: " + code); System.out.print(", 分数: " + score); System.out.print("\n"); } // 完成后关闭 rs.close(); 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(); } } System.out.println("Goodbye!"); } } ```
为什么java显示数据库连接成功但是却显示不出表
代码如下 //连接数据库且显示 Vector rowData,columnNames; columnNames = new Vector(); rowData = new Vector(); columnNames.add("学号"); columnNames.add("学生姓名"); columnNames.add("性别"); columnNames.add("出生日期"); columnNames.add("班级"); columnNames.add("学院"); columnNames.add("年级"); try { connect_sql consql = new connect_sql();//创建对象 Connection conn = consql.getConnection();//链接数据库 try { Statement sta = conn.createStatement();//创建sql语句的接口 ResultSet result = sta.executeQuery("select*from student");//result接受语句选中student表 ResultSetMetaData metaData = result.getMetaData();//接受result中的元数据 while(result.next()) { Vector hang = new Vector(); int id = result.getInt(1); String name = result.getString(2); String sex = result.getString(3); String brithday = result.getString(4); String className = result.getString(5); String insititute = result.getString(6); int grade = result.getInt(7); hang.add(id);hang.add(name);hang.add(sex);hang.add(brithday); hang.add(className);hang.add(insititute);hang.add(grade); rowData.add(hang); } } catch(Exception e) { e.printStackTrace(); conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } DefaultTableModel model = new DefaultTableModel(rowData,columnNames); JTable jTable = new JTable(model);//创建表格组件 jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); jsp.add(jTable); } }
C++连接mysql数据库时,用getString()方法总是出错
> http://www.cnblogs.com/joeblackzqq/p/4332945.html 我按照上面这个链接的教程,用了第二种Connector C++的方法,配置好boost的路径和mysql的路径后,就修改了一下范例的代码: ``` #include <iostream> #include <map> #include <string> #include <memory> #include "mysql_driver.h" #include "mysql_connection.h" #include "cppconn/driver.h" #include "cppconn/statement.h" #include "cppconn/prepared_statement.h" #include "cppconn/metadata.h" #include "cppconn/exception.h" using namespace std; using namespace sql; int main() { sql::mysql::MySQL_Driver *driver = 0; sql::Connection *conn = 0; try { driver = sql::mysql::get_mysql_driver_instance(); conn = driver->connect("tcp://localhost:3306/tree", "root", "123"); cout << "连接成功" << endl; } catch (...) { cout << "连接失败" << endl; } sql::Statement* stat = conn->createStatement(); stat->execute("set names 'gbk'"); ResultSet *res; res = stat->executeQuery("SELECT * FROM testuser"); while (res->next()) { cout << "Id :" << res->getInt("id") << endl; cout << "Name :" << res->getString("name") << endl; //cout << "Address :" << res->getString("address") << endl; } if (conn != 0) { delete conn; } system("pause"); } ``` 为此我创建了一个数据库tree和表testuser: ``` create database tree; use tree; create table testuser( id INT(4) PRIMARY KEY, name CHAR(25), address varchar(45) ); desc testuser; insert into testuser values(1,'Tom','China Beijing'), (2,'Amy','America NewYork'); select*from testuser; ``` 准备工作都做好了,然后就开始执行: 问题来了: ![这个是运行后的截图:](https://img-ask.csdn.net/upload/201602/10/1455080707_998865.png) ![就弹出了这个错误](https://img-ask.csdn.net/upload/201602/10/1455080737_523258.png) ![点击调试后,显示这个错误信息:](https://img-ask.csdn.net/upload/201602/10/1455080768_480387.png) ![我注释掉getString()方法后,就可以运行,而且连接也是成功的:](https://img-ask.csdn.net/upload/201602/10/1455080792_779487.png) ![而且两次同时都有这些错误信息:](https://img-ask.csdn.net/upload/201602/10/1455080844_811925.png)
quartz与mysql使用同一个数据源,请求不到连接
最近在做项目合并 本来的quartz与mysql合并到同一个数据库 我将quartz的DataSource设置为原来的mysql数据源(BoneCP) 在服务器报错 ``` 2020-01-07 11:40:10.163 [schedulerFactoryBean_QuartzSchedulerThread] ERROR [org.quartz.core.ErrorLogger-2460] An error occurred while scanning for the next triggers to fire. org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springNonTxDataSource.schedulerFactoryBean': java.sql.SQLException: Timed out waiting for a free available connection. at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:168) at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3774) at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2759) at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264) Caused by: java.sql.SQLException: Timed out waiting for a free available connection. at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:503) at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114) at org.springframework.scheduling.quartz.LocalDataSourceJobStore$2.getConnection(LocalDataSourceJobStore.java:135) at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:108) at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:165) ... 3 common frames omitted ``` BoneCP设置由原来的2个分区2个最大连接 改为4个分区5个最大连接 还是报这个错 ![图片说明](https://img-ask.csdn.net/upload/202001/08/1578475058_741073.png) 另外 quartz.properties的配置数据源 直接写数据库配置能成功 但是如果写成${}这种形式就不能成功 ``` org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'myDS': java.sql.SQLException: Connections could not be acquired from the underlying database! at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:777) at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:71) at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3213) at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3836) at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.initialize(JobStoreSupport.java:3821) at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:688) at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:580) at org.quartz.impl.StdScheduler.start(StdScheduler.java:142) at org.springframework.scheduling.quartz.SchedulerFactoryBean$1.run(SchedulerFactoryBean.java:708) Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at org.quartz.utils.PoolingConnectionProvider.getConnection(PoolingConnectionProvider.java:247) at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:108) at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:774) ... 8 common frames omitted Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 12 common frames omitted ```
java连接MYSQL数据库第一次可以,第二次报错
做项目在做一个用户首次登陆输入手机号码,发送随机密码的功能模块,首次点击完全没问题,系统会发送短信(中国移动的短信机的原理是连接它的数据库,插入一条数据即可)问题就出在连接数据库的问题上,再次发送,则后台报错ResultSet is from UPDATE. No Data.。 报错信息如下 ``` 严重: Exception occurred during processing request: ResultSet is from UPDATE. No Data. java.sql.SQLException: ResultSet is from UPDATE. No Data. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7152) at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3867) at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3404) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2385) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at DAO.dbconnection2.<init>(dbconnection2.java:16) at action.testsendaction.execute(testsendaction.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ``` dbconnection2.java 是创建连接,代码如下: ``` package DAO; import java.sql.Connection; import java.sql.DriverManager; public class dbconnection2 { private static final String DRIVER = "com.mysql.jdbc.Driver"; private static final String URL = "jdbc:mysql://*******:3306/mas?useUnicode=true&characterEncoding=gb2312"; private static final String USER = "ywz"; private static final String PASSWORD = "yw690"; private Connection con; public dbconnection2() throws Exception{ Class.forName(DRIVER); this.con = DriverManager.getConnection(URL, USER, PASSWORD); } public Connection getConnection() { return this.con; } public void closecon() throws Exception { if(this.con != null) { try { this.con.close(); } catch(Exception e) { throw e; } } } } ``` action代码: ``` public class testsendaction extends ActionSupport{ private String list; public String getList() { return list; } public void setList(String list) { this.list = list; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } private String content; public String execute() throws Exception{ dbconnection2 dbc2 = new dbconnection2(); Statement s1 = dbc2.getConnection().createStatement(); Random ran = new Random(); String pwd = ""; for(int i=0;i<6;i++) { pwd += ran.nextInt(10)+""; } System.out.println("ranpwd="+pwd); String mess = "本信息来自工资查询系统,用于用户的首次登陆,登陆密码为:"+pwd+" ,登陆成功后,请自行修改密码。"; String send = "insert into api_mt_6(mobiles,content) values('"+list+"','"+mess+"')"; s1.executeUpdate(send); System.out.println("send:"+send); s1.close(); dbc2.closecon(); return SUCCESS; } } ``` 报错是在数据库连接的new语句上。 连接最后也有关闭。但是就是不能进行二次访问数据库。只能重启下tomcat,然后又可以登录一次,第二次也无法连接了。 找了好久都没发现原因,希望大家帮帮忙 ,谢谢了!
jdbc连接数据库,查询成功返回数据但是还是报错java.sql.SQLException: Operation not allowed after ResultSet closed 这是怎么回事?
try { Class.forName("com.mysql.jdbc.Driver"); String ur1="jdbc:mysql://localhost:3306/lingshi"; String username="root"; String password="root"; Connection con=DriverManager.getConnection(ur1,username,password); Statement stmt=con.createStatement(); String sql1="select * from guogan"; ResultSet rs1=stmt.executeQuery(sql1); while(rs1.next()){ String id=rs1.getString(1); System.out.print(id+"\t"); String name=rs1.getString("name"); System.out.print(name+"\t"); String price=rs1.getString(3); System.out.print(price+"\t"); String weight=rs1.getString("weight"); System.out.print(weight+"\t"); String birthdate=rs1.getString("birthdate"); System.out.print(birthdate+"\t"); String enddate=rs1.getString("enddate"); System.out.print(enddate+"\t"); String PD=rs1.getString("PD"); System.out.print(PD+"\t"); rs1.close(); stmt.close(); con.close(); } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch(SQLException e1){ e1.printStackTrace(); } 我的结果如下 1 芒果干 13.00 106g 2019.12.29 2020.12.29 12months java.sql.SQLException: Operation not allowed after ResultSet closed at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
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 家里有网,每...
剑指Offer对答如流系列 - 重建二叉树
面试题6:重建二叉树 题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建出图2.6所示的二叉树并输出它的头结点。二叉树结点的定义如下: class TreeNode{ int val; TreeNode l...
史上最全的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岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
一份王者荣耀的英雄数据报告
咪哥杂谈本篇阅读时间约为 6 分钟。1前言前一阵写了关于王者的一些系列文章,从数据的获取到数据清洗,数据落地,都是为了本篇的铺垫。今天来实现一下,看看不同维度得到的结论。2环境准备本次实...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
立即提问