将数据保存到mysql工作台时出错

ibrsph3r  于 2021-07-06  发布在  Java
关注(0)|答案(3)|浏览(325)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

上个月关门了。
改进这个问题
这是我的mysqldatabase:enter image 此处为说明
在此处输入图像描述
这里是代码输入图像描述
在此处输入图像描述
错误消息:run:thg 12 03,2020 9:45:51 ch program.studentmodify insert severe:null com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:您的sql语法有错误;请查看与您的mysql服务器版本对应的手册,以了解使用接近'number'值('sdsd','male',23,'sdsd',的正确语法,java.base/jdk.internal.reflect.nativeconstructoraccessorimpl.newinstance0(本机方法)的java.base/jdk.internal.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl)的第1行中的“232323”)。java:62)在java.base/jdk.internal.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl。java:45)在java.base/java.lang.reflect.constructor.newinstancewithcaller(constructor。java:500)在java.base/java.lang.reflect.constructor.newinstance(constructor。java:481)在com.mysql.jdbc.util.handlenewinstance(util。java:403)在com.mysql.jdbc.util.getinstance(util。java:386)在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror。java:944)在com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio。java:3933)在com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio。java:3869)在com.mysql.jdbc.mysqlio.sendcommand(mysqlio。java:2524)在com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio。java:2675)在com.mysql.jdbc.connectionimpl.execsql(connectionimpl。java:2465)在com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement。java:1915)在com.mysql.jdbc.preparedstatement.execute(preparedstatement。java:1254)在program.studentmodify.insert(studentmodify。java:79)在program.studentjframe.btsaveactionperformed(studentjframe。java:260)在program.studentjframe$3.actionperformed(studentjframe。java:111)在java.desktop/javax.swing.abstractbutton.fireactionperformed(abstractbutton。java:1967)在java.desktop/javax.swing.abstractbutton$handler.actionperformed(abstractbutton。java:2308)在java.desktop/javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel。java:405)在java.desktop/javax.swing.defaultbuttonmodel.setpressed(defaultbuttonmodel。java:262)在java.desktop/javax.swing.plaf.basic.basicbuttonlistener.mousereleased(basicbuttonlistener。java:279)在java.desktop/java.awt.component.processmouseevent(组件。java:6636)在java.desktop/javax.swing.jcomponent.processmouseevent(jcomponent。java:3342)在java.desktop/java.awt.component.processevent(component。java:6401)在java.desktop/java.awt.container.processevent(container。java:2263)在java.desktop/java.awt.component.dispatcheventimpl(组件。java:5012)在java.desktop/java.awt.container.dispatcheventimpl(container。java:2321)在java.desktop/java.awt.component.dispatchevent(component。java:4844)在java.desktop/java.awt.lightweightdispatcher.RetargeMouseeEvent(容器。java:4919)在java.desktop/java.awt.lightweightdispatcher.processmouseevent(容器。java:4548)在java.desktop/java.awt.lightweightdispatcher.dispatchevent(container。java:4489)在java.desktop/java.awt.container.dispatcheventimpl(container。java:2307)在java.desktop/java.awt.window.dispatcheventimpl(窗口。java:2764)在java.desktop/java.awt.component.dispatchevent(组件。java:4844)在java.desktop/java.awt.eventqueue.dispatcheventimpl(eventqueue。java:772)在java.desktop/java.awt.eventqueue$4.run(eventqueue。java:721)在java.desktop/java.awt.eventqueue$4.run(eventqueue。java:715)在java.base/java.security.accesscontroller.doprivileged(accesscontroller。java:391)在java.base/java.security.protectiondomain$javasecurityaccessimpl.dointersectionprivilege(protectiondomain。java:85)在java.base/java.security.protectiondomain$javasecurityaccessimpl.dointersectionprivilege(protectiondomain。java:95)在java.desktop/java.awt.eventqueue$5.run(eventqueue。java:745)在java.desktop/java.awt.eventqueue$5.run(eventqueue。java:743)在java.base/java.security.accesscontroller.doprivileged(accesscontroller。java:391)在java.base/java.security.protectiondomain$javasecurityaccessimpl.dointersectionprivilege(protectiondomain。java:85)在java.desktop/java.awt.eventqueue.dispatchevent(事件队列)。java:742)在java.desktop/java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread。java:203)在java.desktop/java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread。java:124)在java.desktop/java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread。java:113)在java.desktop/java.awt.eventdispatchthread.pumpevents(eventdispatchthread。java:109)在java.desktop/java.awt.eventdispatchthread.pumpevents(eventdispatchthread。java:101)在java.desktop/java.awt.eventdispatchthread.run(eventdispatchthread。java:90)

jgwigjjp

jgwigjjp1#

也许你可以试试,而不是:
字符串url=“jdbc:mysql://localhost:3306/studentmanagement?&usessl=false"
尝试:
字符串url=“jdbc:mysql://localhost:3306/studentmanagement?autoreconnet=true&usessl=false"

xu3bshqb

xu3bshqb2#

您的sql查询中有电话号码。
在您的代码中,每次使用方法时都可以打开和关闭连接您可以在不同的方法中移动连接和关闭连接
例如:

public Connection connect() throws SQLException {
        Connection connection = null;
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        connection = DriverManager.getConnection(URL,USER,PASSWORD);

        return connection;
    }

  public void disconnect(Connection connection) throws SQLException {
        connection.close();
    }
l7mqbcuq

l7mqbcuq3#

也许你应该用phonenumber这样的词写“phone number”。
或者写 Phone Number 在insert语句中的单词周围使用反勾号—在create语句中,在字段名周围使用反勾号。

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 'Number) 
values('sdsdsd','Male',23,'sdsdsd','232323')'

“号码”可能是“电话号码”的第二部分。

相关问题