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

com.bjsxtjava.sql.Connectionjava.sql.DriverManagerjava.sql.SQLExceptionjava.sql.StatementJdbcTest {
    (String department_namelocation_id){
        Connection conn = Statement statement = {
            Class.()conn =
            DriverManager.()String sql = +department_name++location_id+statement = conn.createStatement()i = statement.executeUpdate(sql)System..println(i)} (Exception e) {
            e.printStackTrace()}{
            (statement!=){
                {
                    statement.close()} (SQLException e) {
                    e.printStackTrace()}
            }

            (conn!=){
                {
                    conn.close()} (SQLException e) {
                    e.printStackTrace()}
            }
        }
    }
    (String[] args) {
        JdbcTest jdbc = JdbcTest()jdbc.insertDepartments()}
}


按照视频来的,怎么有这个错误

Fri Oct 16 00:23:35 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

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 '8)' at line 1

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:425)

at com.mysql.jdbc.Util.getInstance(Util.java:408)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3914)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2491)

at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1552)

at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2607)

at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1480)

at com.bjsxt.JdbcTest.insertDepartments(JdbcTest.java:23)

at com.bjsxt.JdbcTest.main(JdbcTest.java:49)


Process finished with exit code 0


怎么解

JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 1141楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 1143楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库 1145楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 1149楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 1150楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 1151楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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