Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

时间:2022-10-20 20:09:15

今天调试程序是遇到了,下面的一个问题。我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的问题,原因大概有两个,一是:结果集中的字段含有对应的数据库产品的关键字,二是:在xml文件中的SQL语句中,两个填充变量间没有写逗号,我仔细分析自己的SQL语句,觉得有可能是第二种原因!where 1 = 1 order by ? ?占位符的方式传递参数是确实没有逗号,我将SQL语句中order by #{sortName} #{sortOrder} 改写为<![CDATA[order by ${sortName} ${sortOrder} ]]>这种方式其他不变,问题就解决了!

在这里想说一下在对应的与数据库交互的XML文件中用#和$传递参数的特点

#是以占位符的形式来传递对应变量的参数值的,框架会对传入的参数做预编译的动作,用$时会将传入的变量的参数值原样的传递过去

[DEBUG] 2013-08-28 14:51:09 :ooo Using Connection [jdbc:oracle:thin:@10.9.203.83:1521:orclacms, UserName=SALES, Oracle JDBC driver]     [DEBUG] 2013-08-28 14:51:09 :==>  Preparing: select * from ( select row_.*, rownum rownum_ from ( select ii.iata_code,ii.agent_name, di.iata_code agent_iata_code,di.agent_china_name from agent_table_iata_imp ii full join (select iata_code,agent_china_name from agent_table where delete_index = 0) di on ii.iata_code = di.iata_code where 1 = 1 order by ? ? ) row_ ) where rownum_ >= 1 and rownum_ < 31     [DEBUG] 2013-08-28 14:51:09 :==> Parameters: iata_code(String), asc(String)     [INFO ] 2013-08-28 14:51:09 :Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]     [INFO ] 2013-08-28 14:51:09 :SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]     org.springframework.jdbc.BadSqlGrammarException: ### Error querying database.  Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

### The error may involve AgentTableMapper.searchAgentValidate-Inline ### The error occurred while setting parameters ### Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)  at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)  at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)  at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)  at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)  at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:360)  at $Proxy9.selectList(Unknown Source)  at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:197)  at com.ca.agent.dao.AgentTableDao.searchAgentValidate(AgentTableDao.java:28)  at com.ca.agent.service.impl.AgentTableImpl.searchAgentDataVlidate(AgentTableImpl.java:111)  at com.ca.agent.action.AgentTableAction.searchAgentValidateList(AgentTableAction.java:83)  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  at java.lang.reflect.Method.invoke(Method.java:597)  at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)  at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)  at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)  at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)  at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)  at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)  at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)  at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)  at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  at com.frame.action.ChineseFilter.doFilter(ChineseFilter.java:61)  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)  at java.lang.Thread.run(Thread.java:619)

Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名的更多相关文章

  1. ORA&colon;01745 无效的主机 绑定变量名

    原因是:mybatis中的mapping映射时,sql语句中忘了加逗号,且逗号处有换行

  2. mybatis 执行查询时报错 【Error querying database&period; Cause&colon; java&period;sql&period;SQLException&colon; Error setting driver on UnpooledDataSource&period; Cause&colon; java&period;lang&period;ClassNotFoundException&colon; Cannot find class&colon; 】

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLE ...

  3. org&period;apache&period;ibatis&period;exceptions&period;PersistenceException&colon; &num;&num;&num; Error querying database&period; Cause&colon; java&period;sql&period;SQLException&colon; The server time zone value &&num;39&semi;&&num;214&semi;&&num;208&semi;&&num;185&semi;&&num;250&semi;&&num;177&semi;&&num;234&semi;&&num;215&semi;&&num;188&semi;&&num;202&semi;&&num;177&semi;&&num;188&semi;&&num;228&semi;&&num;39&semi; is unrecognized or represents mor

    今天在用junit测试mybits程序是遇到一个问题,报错为: org.apache.ibatis.exceptions.PersistenceException: ### Error queryin ...

  4. 初学MyBatis(踩坑)Error querying database&period; Cause&colon; java&period;sql&period;SQLException&colon; java&period;lang&period;ClassCastException&colon; java&period;math&period;BigInteger cannot be cast to java&period;lang&period;Long

    最近在学习Mybatis,代码全部根据教程写好了,一运行结果报了一个错误,主要错误内容: Caused by: org.apache.ibatis.exceptions.PersistenceExce ...

  5. Error updating database&period; Cause&colon; java&period;sql&period;SQLException&colon; Access denied for user &&num;39&semi;&dollar;&lbrace;username&rcub;&&num;39&semi;&commat;&&num;39&semi;localhost&&num;39&semi; &lpar;using password&colon; YES&rpar;

    导入别人的项目,出现一个错误,经过排查,是db.properties配置文件中的用户名与Mybatis-conf.xml配置文件中调用的用户名不一致所导致的 (db.properties中用的是nam ...

  6. Oracle批量插入数据SQL语句太长出错:无效的主机&sol;绑定变量名

    Oracle数据库,用mybatic批量插入数据: <insert id="saveBatch" parameterType="io.renren.entity.N ...

  7. mysql 执行报错:Error querying database&period; Cause&colon; java&period;sql&period;SQLSyntaxErrorException&colon;which is not functionally dependent on columns in GROUP BY clause&semi; this is incompatible with sql&lowbar;mode&equals;only&lowbar;full&lowbar;group&lowbar;by

    1.这个错误发生在mysql 5.7 版本及以上版本会出现的问题: mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严 ...

  8. org&period;springframework&period;jdbc&period;UncategorizedSQLException&colon; &num;&num;&num; Error updating database&period; Cause&colon; java&period;sql&period;SQLException&colon; Incorrect string value&colon; &&num;39&semi;&bsol;xE2&bsol;x80&bsol;x8B&bsol;xE2&bsol;x80&bsol;x8B&period;&period;&period;&&num;39&semi; for column &&num;39&semi;pro&lowbar;backgroud&&num;39&semi; at row

    如果你在mysql数据库中,将所有的表的编码格式设置成为utf-8之后还是不行,那就试试这个吧:ALTER TABLE your_database_name.your_table CONVERT TO ...

  9. &num;&num;&num; Error querying database&period; Cause&colon; java&period;lang&period;IllegalArgumentException&colon; invalid comparison&colon; cn&period;xiaojian&period;blog&period;po&period;BlogType and java&period;lang&period;String &num;&num;&num; Cause&colon; java&period;lang&period;IllegalArgumentException&colon; &period;&period;&period;

    ### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: cn.xiaoj ...

随机推荐

  1. C语言 第二章 数据类型、变量和输入函数

    一.数据类型简介 在 C 语言中,数据类型指的是用于声明不同类型的变量或函数的一个广泛的系统.变量的类型决定了变量存储占用的空间,以及如何解释存储的位模式. 类型转换: 类型 存储大小 值范围 cha ...

  2. Android&period;mk文件语法规范 原文

    序言:------------- 此文档旨在描述Android.mk文件的语法,Android.mk文件为Android NDK(原生开发)描述了你C/C++源文件.为了明白下面的内容,你必须已经阅读 ...

  3. C语言数据结构----栈的定义及实现

    本节主要说的是数据结构中的栈的基本定义和实现的方式,其中实现的方式采用的是复用顺序表和单向链表的方式. 一.栈的基本定义 1.栈是一种特殊的线性表,只能从固定的方向进出,而且栈进出的基本原则是:先进栈 ...

  4. 3wwang的2019计划

    1.探究osg类生物----系列(35天) 已完结 [置顶]探索未知种族之osg类生物[目录]​www.3wwang.cn 2.osg中的设计模式---系列(15天) 正在创作... osg中抽象工厂 ...

  5. 只要一行代码求一串字符中某字符(串)出现次数,c&num;

    这里只要一行代码就行. static void Main(string[] args) { string str = "qwerwqr;sfdsfds;fdfdsf;dfsdfsdf;dsf ...

  6. 【Mybatis】1、Mybatis拦截器学习资料汇总

    MyBatis拦截器原理探究 http://www.cnblogs.com/fangjian0423/p/mybatis-interceptor.html [myBatis]Mybatis中的拦截器 ...

  7. WPF loading遮罩层 LoadingMask

    原文:WPF loading遮罩层 LoadingMask 大家可能很纠结在异步query数据的时候想在wpf程序中显示一个loading的遮罩吧 今天就为大家介绍下遮罩的制作 源码下载 点击此处 先 ...

  8. C&num;绘制三角形并填充,使用winform实现qq聊天气泡

    首先是需求,需要制作一个聊天气泡, 但是winform中有没有类似Android的.9图,只有自己设计图形拼接气泡. 第一种是绘制空心三角形,第二种是绘制三角形区域,可以指定RGB颜色. privat ...

  9. 360在线网站安全检测,web安全测试AppScan扫描工具,XSS常用的攻击手法

    360在线网站安全检测,web安全测试AppScan扫描工具,XSS常用的攻击手法 如何做好网站的安全性测试 360网站安全检测 - 在线安全检测,网站漏洞修复,网站后门检测http://websca ...

  10. jsp 页面间传递参数

    JSP页面间传递参数是经常需要使用到的功能,有时还需要多个JSP页面间传递参数.下面介绍一下实现的方法. (1)直接在URL请求后添加 如:< a href="thexuan.jsp? ...