会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132455个问题

jdbc链接数据库出现问题:

1:代码

package sxt.com;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest {

    //向departments表添加一条数据
    public void insertDepartments(String department_name){
        Connection conn = null;
        Statement state = null;

        //驱动注册
        try {
            Class.forName("com.mysql.jdbc.Driver");
            //创建链接
             conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/sxt?characterEncoding=utf-8","root","root");
            //执行sql
            String sql = "insert into department values(default,‘研发部’)";
             state = conn.createStatement();
           int flag = state.executeUpdate(sql);
            System.out.println(flag);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (state != null){
                try {
                    state.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
        }
        if (conn != null){
            try {
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }

    }

    public static void main(String[] args) {
        JdbcTest test = new JdbcTest();
        test.insertDepartments("研发部");
    }
}

2:问题:


image.png

JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 31533楼
JAVA 全系列/第九阶段:Spring Boot实战/Spring Boot 31535楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:使用RabbitMQ实现大广告异步缓存 31537楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 31538楼
JAVA 全系列/第十三阶段:高性能数据处理、NoSQL、分库分表/MyCat 31539楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 31541楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库的使用 31542楼

微信图片_20200701215311.jpg

老师,我这个下面没有您打开后,显示的最后一行的内容:

127.0.0.1 www.xmind.net


并且,我添加IP和域名绑定的信息后,提示我拒绝访问

微信图片_20200701215718.jpg

JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 31543楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 31544楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637