Spring报错: Unable to determine the correct call signature
来源:互联网 发布:彩虹六号围攻网络eas 编辑:程序博客网 时间:2024/06/03 15:22
Spring 中 SQL 的存储过程
在运行MainApp时报错:
--------记录列表--------ID:1,Name黑熊,Age11ID:2,Name加菲猫,Age13ID:3,Name阿丽,Age15--------ID为2的记录信息--------Exception in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: Unable to determine the correct call signature - no procedure/function/signature for 'getrecord' at org.springframework.jdbc.core.metadata.GenericCallMetaDataProvider.processProcedureColumns(GenericCallMetaDataProvider.java:347) at org.springframework.jdbc.core.metadata.GenericCallMetaDataProvider.initializeWithProcedureColumnMetaData(GenericCallMetaDataProvider.java:112) at org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory$1.processMetaData(CallMetaDataProviderFactory.java:133) at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:336) at org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory.createMetaDataProvider(CallMetaDataProviderFactory.java:73) at org.springframework.jdbc.core.metadata.CallMetaDataContext.initializeMetaData(CallMetaDataContext.java:242) at org.springframework.jdbc.core.simple.AbstractJdbcCall.compileInternal(AbstractJdbcCall.java:303) at org.springframework.jdbc.core.simple.AbstractJdbcCall.compile(AbstractJdbcCall.java:288) at org.springframework.jdbc.core.simple.AbstractJdbcCall.checkCompiled(AbstractJdbcCall.java:348) at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:363) at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:198) at com.joey.JdbcCall.StudentJDBCTemplate.getStudent(StudentJDBCTemplate.java:37) at com.joey.JdbcCall.MainApp.main(MainApp.java:27)
MainApp.java
package com.joey.JdbcCall;import java.util.List;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("jdbcCallBeans.xml"); StudentJDBCTemplate studentJDBCTemplate = (StudentJDBCTemplate) context.getBean("studentJDBCTemplate"); /*System.out.println("--------添加记录--------"); studentJDBCTemplate.create("黑熊", 11); studentJDBCTemplate.create("加菲猫", 13); studentJDBCTemplate.create("阿丽", 15);*/ System.out.println("--------记录列表--------"); List<Student> students=studentJDBCTemplate.listStudent(); for (Student student : students) { System.out.print("ID:"+student.getId()); System.out.print(",Name"+student.getName()); System.out.println(",Age"+student.getAge()); } System.out.println("--------ID为2的记录信息--------"); Student student=studentJDBCTemplate.getStudent(2); System.out.print("ID:"+student.getId()); System.out.print(",Name"+student.getName()); System.out.println(",Age"+student.getAge()); }}
StudentJDBCTemplate.java
package com.joey.JdbcCall;import java.util.List;import java.util.Map;import javax.sql.DataSource;import org.springframework.jdbc.core.JdbcTemplate;import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;import org.springframework.jdbc.core.namedparam.SqlParameterSource;import org.springframework.jdbc.core.simple.SimpleJdbcCall;public class StudentJDBCTemplate implements StudentDAO{ private DataSource dataSource; private SimpleJdbcCall jdbcCall; @Override public void setDataSource(DataSource dataSource) { this.dataSource=dataSource; this.jdbcCall=new SimpleJdbcCall(dataSource) .withProcedureName("getRecord"); } @Override public void create(String name, Integer age) { JdbcTemplate jdbcTemplateObject=new JdbcTemplate(dataSource); String SQL="insert into Student(name,age) values(?,?)"; jdbcTemplateObject.update(SQL,name,age); System.out.println("Created Record Name = "+name+" Age = "+age); return; } @Override public Student getStudent(Integer id) { SqlParameterSource in=new MapSqlParameterSource().addValue("in_id", id); Map<String, Object>out=jdbcCall.execute(in); Student student = new Student(); student.setId(id); student.setName((String) out.get("out_name")); student.setAge((Integer) out.get("out_age")); return student; } @Override public List<Student> listStudent() { JdbcTemplate jdbcTemplateObject=new JdbcTemplate(dataSource); String SQL="select * from Student"; List<Student> students=jdbcTemplateObject.query(SQL,new StudentMapper()); return students; }}
阅读全文
0 0
- Spring报错: Unable to determine the correct call signature
- Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collec
- hive select报错 Unable to determine if hdfs
- Maven使用tomcat7运行报错:Unable to determine URL for WEB-INF/classes
- 大数据学习15:报错 FAILED: SemanticException Unable to determine if
- VitrualBox 做共享ASM磁盘,测试通不过,报rac1:Unable to determine the sharedness of /dev/sdb on nodes:
- Eclipse 报错Error generating final archive: Unable to get debug signature key
- How to determine the correct setting for JOB_QUEUE_PROCESSES (Doc ID 578831.1)
- TFS2010问题:unable to determine the workspace for this solution
- Resolved Unlocking issue>unable to determine the source control server
- Spring与Hibernate整合报错:unable to get the default bean validation
- 测试spring和Hibernate的整合,报错: “Unable to get the default Bean Validation”
- Genymotion报错:unable to connect to the virtual device
- mwactl: Unable to determine MWA_TOP.
- powerDesinger逆向工程报错(Unable to list the tables)
- powerDesigner逆向工程报错:Unable to list the users.
- maven打包报错Unable to locate the JavacCompiler in
- npm总是报错:unable to verify the first certificate
- firewalld火墙设置
- API开发之封装接口数据返回函数
- OpenJ_Bailian 4127 迷宫问题(DFS+BFS)
- 欢迎使用CSDN-markdown编辑器
- poj2828——Buy Tickets
- Spring报错: Unable to determine the correct call signature
- (一)Q-learning
- 电脑上调试手机网站的几种方法
- c++中的stl排序
- 使用 Istio Service Mesh 管理微服务
- 关于Audio你应该知道的一点知识
- 图的深度(广度)优先搜索
- tensorflow 安装
- CNN网络中,feature map感受野的计算