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

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

測(cè)試UserDAOImpl.java,異常:sql語(yǔ)句錯(cuò)誤。謝各位大神指點(diǎn)了!

Hibernate:?
????
from
????users?
where
????username=??
????and?password=?
二月?15,?2017?4:44:10?下午?org.hibernate.engine.jdbc.spi.SqlExceptionHelper?logExceptions
WARN:?SQL?Error:?1064,?SQLState:?42000
二月?15,?2017?4:44:10?下午?org.hibernate.engine.jdbc.spi.SqlExceptionHelper?logExceptions
ERROR:?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?'from?users?where?username='xinhou'?and?password='666666''?at?line?1
org.hibernate.exception.SQLGrammarException:?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?'from?users?where?username='xinhou'?and?password='666666''?at?line?1
?at?org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
?at?org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
?at?org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
?at?org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
?at?org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
?at?org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
?at?com.sun.proxy.$Proxy5.executeQuery(Unknown?Source)
?at?org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
?at?org.hibernate.loader.Loader.doQuery(Loader.java:829)
?at?org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
?at?org.hibernate.loader.Loader.doList(Loader.java:2438)
?at?org.hibernate.loader.Loader.doList(Loader.java:2424)
?at?org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2254)
?at?org.hibernate.loader.Loader.list(Loader.java:2249)
?at?org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:331)
?at?org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1784)
?at?org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:229)
?at?org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:156)
?at?serviceImpl.UserDAOImpl.userLogin(UserDAOImpl.java:30)
?at?serviceImpl.testUserDAOImpl.testUserLogin(testUserDAOImpl.java:14)
?at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
?at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
?at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
?at?java.lang.reflect.Method.invoke(Method.java:497)
?at?org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
?at?org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
?at?org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
?at?org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
?at?org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
?at?org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
?at?org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
?at?org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
?at?org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
?at?org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
?at?org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
?at?org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
?at?org.junit.runners.ParentRunner.run(ParentRunner.java:309)
?at?org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
?at?org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
?at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
?at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
?at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
?at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused?by:?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?'from?users?where?username='xinhou'?and?password='666666''?at?line?1
?at?com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
?at?com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
?at?com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
?at?com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
?at?com.mysql.jdbc.Connection.execSQL(Connection.java:3249)
?at?com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1268)
?at?com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1403)
?at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
?at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
?at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
?at?java.lang.reflect.Method.invoke(Method.java:497)
?at?org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
public?class?UserDAOImpl?implements?UsersDAO{
?@SuppressWarnings({?"rawtypes"?})
?@Override
?public?boolean?userLogin(Users?u)?{
??//事務(wù)對(duì)象
??Transaction?tx?=?null;
??String?hql?=?"";
??
??try{
???Session?session?=?MyHibernateSessionFactory.getSessionFactory().getCurrentSession();
???tx?=?session.beginTransaction();
???hql?=?"from?users?where?username=??and?password=?";
???Query?query?=?session.createSQLQuery(hql);
???query.setParameter(0,?u.getUsername());
???query.setParameter(1,?u.getPassword());
???List?list?=?query.list();
???tx.commit();
???if?(list.size()?>?0){
????return?true;
???}?else?{
????return?false;
???}
??}?catch(Exception?e){
???e.printStackTrace();
???return?false;
??}?finally{
???if?(tx?!=?null){
????
????tx?=?null;????
???}
??}
??
?}
?
}
<?xml?version="1.0"?>
<!DOCTYPE?hibernate-mapping?PUBLIC?"-//Hibernate/Hibernate?Mapping?DTD?3.0//EN"
????????"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
????<class?name="entity.Users"?table="users">
????????<id?name="uid"??type="int">
????????????<generator?class="native"/>??<!--?native表示自動(dòng)增長(zhǎng)類(lèi)型?-->
????????</id>
????????<property?name="username"?type="java.lang.String"></property>
????????<property?name="password"?type="java.lang.String"></property>
????</class>
</hibernate-mapping>


正在回答

3 回答

?Query?query?=?session.createSQLQuery(hql);這句應(yīng)該改成?Query?query?=?session.createQuery(hql)吧?

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

陷入編程無(wú)法自拔的江北 提問(wèn)者

非常感謝!
2017-02-16 回復(fù) 有任何疑惑可以回復(fù)我~

一:hql語(yǔ)句里的是實(shí)體類(lèi)對(duì)象,而不是table.

二:createSQLQuery()用原生SQL語(yǔ)句查詢(xún),cerateQuery()用hql語(yǔ)句查詢(xún).


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

一:hql語(yǔ)句里的是實(shí)體類(lèi)對(duì)象,而不是table.

二:createSQLQuery()用原生SQL語(yǔ)句查詢(xún),cerateQuery()用hql語(yǔ)句查詢(xún).

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

舉報(bào)

0/150
提交
取消

測(cè)試UserDAOImpl.java,異常:sql語(yǔ)句錯(cuò)誤。謝各位大神指點(diǎn)了!

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

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

幫助反饋 APP下載

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

公眾號(hào)

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