最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

占位符報(bào)語(yǔ)法錯(cuò)誤

新增和更新方法類里面的占位符能夠跑起來(lái),但是刪除和查詢單個(gè)女神里面的占位符就會(huì)報(bào)語(yǔ)法錯(cuò)誤,將占位符手動(dòng)改為具體整型數(shù)字就可以正確運(yùn)行。

以下是部分源碼。

//刪除功能代碼塊
	public?void?delPeople?(Integer?id)?throws?SQLException?{
		//獲取數(shù)據(jù)庫(kù)連接
		?Connection?conn?=?DBUtil.getConnection();
		?//編寫(xiě)sql語(yǔ)法規(guī)范的字符串為數(shù)據(jù)庫(kù)修改數(shù)據(jù)
		?String?sql?=?""
		?		+?"?DELETE?FROM?test"
		?		+?"?WHERE?id=?";
		?PreparedStatement?pstmt?=?conn.prepareStatement(sql);
		?
		?pstmt.setInt(1,?id);
		//通過(guò)PreparedStatement對(duì)象執(zhí)行SQL語(yǔ)句
		?pstmt.execute();
	}
//查詢功能代碼塊
	public?People?get?(Integer?id)?throws?Exception?{
		//獲取數(shù)據(jù)庫(kù)連接
		?Connection?conn?=?DBUtil.getConnection();
		?//編寫(xiě)sql語(yǔ)法規(guī)范的字符串為數(shù)據(jù)庫(kù)修改數(shù)據(jù)
		?String?sql?=?""
		?		+?"?SELECT?*?FROM?test"
		?		+?"?WHERE?id=?";
		?PreparedStatement?pstmt?=?conn.prepareStatement(sql);
		?pstmt.setInt(1,?id);
		//通過(guò)PreparedStatement對(duì)象的executeQuery方法查詢數(shù)據(jù)庫(kù)存儲(chǔ)的信息
		?ResultSet?rs?=?pstmt.executeQuery(sql);
		?People?p?=?null;
		?while(rs.next())?{
			?p?=?new?People();
			?p.setAge(rs.getInt("age"));
			?p.setUsername(rs.getString("username"));
			?p.setId(rs.getInt("id"));
			?p.setSex(rs.getInt("sex"));
		?}
		return?p;
	}
//錯(cuò)誤信息
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?'?'?at?line?1
	at?sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native?Method)
	at?sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at?sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at?java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	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:943)
	at?com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
	at?com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
	at?com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
	at?com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
	at?com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2497)
	at?com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2455)
	at?com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1369)
	at?com.javajdbc.dao.PeopleDao.get(PeopleDao.java:103)
	at?com.javajdbc.peopleaction.PeopleAction.main(PeopleAction.java:35)


正在回答

1 回答

問(wèn)題已經(jīng)被我查找API幫助文檔解決了,刪除功能代碼塊沒(méi)有問(wèn)題,出問(wèn)題的是查詢功能代碼塊里面,executeQuery方法不應(yīng)該傳入?yún)?shù),將括號(hào)里面的String字符串去掉即可,希望各位對(duì)各位同學(xué)有幫助。

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

占位符報(bào)語(yǔ)法錯(cuò)誤

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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