第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

不知道是不是是ptmt.execute()的問題

不知道是不是是ptmt.execute()的問題

小小怪下士的榮耀 2018-06-03 18:28:56
import?java.sql.Connection; import?java.sql.PreparedStatement; import?java.sql.ResultSet; import?java.sql.SQLException; import?java.sql.Statement; import?java.util.ArrayList; import?java.util.List; import?com.JDBC.DBUtil; import?model.Emps;public?class?EmpsDao?{ public?void?add(Emps?g)?throws?Exception?{ Connection?conn?=?DBUtil.getConnection(); String?sql?=?""+"insert?into?emp(eid,enmae,job,mal,deptno)"?+?"vlues(?,?,?,?,?)"; PreparedStatement?ptmt?=?null; try?{ ptmt?=?conn.prepareStatement(sql); ?????????ptmt.execute(sql); }catch(SQLException?e)?{ ????????? e.printStackTrace(); } ????????? ptmt.setInt(1,?g.getEid()); ????????? ?????????ptmt.setString(2,?g.getEname()); ????????? ptmt.setString(3,?g.getJob()); ????????? ptmt.setInt(4,?g.getMal()); ????????? ptmt.setInt(5,?g.getDeptno()); ????????? ptmt.execute(); } public?void?update()?{ } public?void?delect()?{ } public?List<Emps>?query()?throws?Exception{ Connection?conn?=?DBUtil.getConnection(); Statement?stmt?=?conn.createStatement(); ResultSet?rs?=?stmt.executeQuery("select?ename,eid?from?emp"); List<Emps>?gs?=?new?ArrayList<Emps>(); Emps?g?=?null; while(rs.next())?{ g?=?new?Emps(); g.setEname(rs.getString("ename")); g.setEid(rs.getInt("eid")); gs.add(g); } return?gs; } public?Emps?get()?{ return?null; } } 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 'vlues(?,?,?,?,?)' at line 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3277) at com.mysql.jdbc.Connection.execSQL(Connection.java:3206) at com.mysql.jdbc.Statement.execute(Statement.java:727) at dao.EmpsDao.add(EmpsDao.java:27) at action.EmpsAction.main(EmpsAction.java:22)Exception in thread "main" 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 'vlues(1012,'?’?é±??“¥','?–??‘?',1000,20)' at line 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882) at dao.EmpsDao.add(EmpsDao.java:42) at action.EmpsAction.main(EmpsAction.java:22)
查看完整描述

4 回答

已采納
?
慕沐9307871

TA貢獻(xiàn)27條經(jīng)驗(yàn) 獲得超9個(gè)贊

兩處錯(cuò)誤:

  1. values 拼寫錯(cuò)誤

  2. “ptmt.execute(sql);”這句應(yīng)該去掉

查看完整回答
1 反對 回復(fù) 2018-06-03
?
產(chǎn)品經(jīng)理不是經(jīng)理

TA貢獻(xiàn)481條經(jīng)驗(yàn) 獲得超143個(gè)贊

你的sql寫錯(cuò)了。

查看完整回答
反對 回復(fù) 2018-06-03
  • 4 回答
  • 0 關(guān)注
  • 3690 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)