Caused by: java.sql.SQLException: The user specified as a definer (''@'') does not exist
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2275)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        ... 73 more

以上的出错是上传新工程到服务器上时出的错。出错的意思是数据库访问时没有‘@’这个用户.这主要是在新建视图和存储过程时,直截在mysql可视图形工具里copy代码到服务器上去运行,mysql里会自动生成一些代码,比如copy出来的视图语句:
-- ----------------------------
-- View structure for `sys_teacher_role_view`
-- ----------------------------
DROP VIEW IF EXISTS `sys_teacher_role_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=``@`` SQL SECURITY DEFINER VIEW `sys_teacher_role_view`
AS select `tea_teacher`.`teaid` AS
`teaid`,`sys_user_role`.`employee_nember` AS
`employee_nember`,`tea_teacher`.`staffnumbers` AS
`staffnumbers`,`tea_teacher`.`teachername` AS
`teachername`,`sys_user_role`.`role_id` AS
`role_id`,`tea_teacher`.`identity_card` AS `identity_card` from
(`tea_teacher` left join `sys_user_role`
on((`sys_user_role`.`employee_nember` = `tea_teacher`.`teaid`)));

应该改为:
-- ----------------------------
-- View structure for `sys_teacher_role_view`
-- ----------------------------
DROP VIEW IF EXISTS `sys_teacher_role_view`;
CREATE VIEW `sys_teacher_role_view`
AS select `tea_teacher`.`teaid` AS
`teaid`,`sys_user_role`.`employee_nember` AS
`employee_nember`,`tea_teacher`.`staffnumbers` AS
`staffnumbers`,`tea_teacher`.`teachername` AS
`teachername`,`sys_user_role`.`role_id` AS
`role_id`,`tea_teacher`.`identity_card` AS `identity_card` from
(`tea_teacher` left join `sys_user_role`
on((`sys_user_role`.`employee_nember` = `tea_teacher`.`teaid`)));

存储过程也是一样的,往往就会忽略这个问题而导致上面的错误

Java调用存储过程时报 The user specified as a definer ('root'@'%') does not exist 解决方法的更多相关文章

  1. clob字段的值插入和查询N种方法【包括java调用存储过程传入clob参数】

    import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import jav ...

  2. Oracle数据库基本操作 (五) —— 使用java调用存储过程

    一.环境准备 登录Oracle数据库scott账号,利用emp进行操作. 1.创建 proc_getyearsal 存储过程 -- 获取指定员工年薪 create or replace procedu ...

  3. java调用存储过程(stored procedures)的HelloWorld例子

    1.java调用存储过程(stored procedures)的HelloWorld程序 有点数据 库基础的人都知道.存储过程(stored procedures)和java没什么关系.它是一段纯粹的 ...

  4. java调用存储过程

    在做java调用sqlserver存储过程时遇到了各种各样的问题,不过在不懈的努力之下这些问题还是得以解决了.今天总结一下遇到的问题以及解决的方法. 首先调用存储过程的方法大家都很清楚: String ...

  5. java调用存储过程和函数

    以对表test进行增,删,改,查进行说明:1.新建表test create table TEST ( TID NUMBER not null, TNAME VARCHAR2(32), TCODE VA ...

  6. 【转】java调用存储过程和函数

    一.概述 如果想要执行存储过程,我们应该使用 CallableStatement 接口. CallableStatement 接口继承自PreparedStatement 接口.所以CallableS ...

  7. java 调用存储过程

    1.java 中调用pl/sql 中的存储过程 call 存储过程的名称(参数名称,参数名称)  在service 层中调用  存储过程  String  sql=" call  proc_ ...

  8. java调用存储过程、存储函数

    需要用到的接口 接口 CallableStatement JDK文档对改接口的说明: public interface CallableStatement extends PreparedStatem ...

  9. Java调用存储过程小结

    学生在学习jdbc的时候,会问到怎么调用存储过程,现在将java调用oracle存储过程的示例总结如下.(关于调用sqlserver的存储过程将在下次进行小结请关注) 一:无返回值的存储过程 存储过程 ...

随机推荐

  1. C# String 前面不足位数补零的方法 PadLeft

    PadLeft(int totalWidth, char paddingChar) //在字符串左边用 paddingChar 补足 totalWidth 长度PadLeft(int totalWid ...

  2. 接收Firfox RESTClient #Post请求

    什么是 RESTClient 请参考:http://www.blogjava.net/paulwong/archive/2014/04/19/412688.html 对接接口时经常会需要传个异步回调消 ...

  3. zookeeper实现商品秒杀抢购

    package com.test; import java.io.IOException; import java.util.List; import java.util.concurrent.Cyc ...

  4. CStdioFile 写文件

    前言: 介绍如何使用 CStdioFile 类去写文件. 完整工程代码,点我下载(请注意工程里面需要包含的 <locale.h>头文件 ) 示例: /// My Add // 获取当前路径 ...

  5. eclipse4.2.1插件安装(二)之Eclipse HTML Editor

    编辑一些页面文件,例如JSP,HTML,JS等,直接用内置的文本编辑器基本比较疯狂,自己选了一个顺手的编辑器,Eclipse HTML Editor! Eclipse HTML编辑器插件主要提供以下功 ...

  6. php configure help

    `configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION].. ...

  7. Linux FTP服务安装和远程登录失败

    问题:本机VPlayer安装pure-ftpd  ftp服务,通过flashfxp从windows连接出现以下错误: [左] 正在连接到 vmare -> IP=192.168.174.133 ...

  8. fuser 命令概述

    fuser 概述 fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息. 例一: #fuser –m –u /mnt/usb1 /mnt/us ...

  9. 解决 IE 不支持 document.getElementsByClassName() 的方法

    //create method getElementsByClassName for document if(!document.getElementsByClassName){ document.g ...

  10. Newtonsoft.Json.dll解析json的dll文件使用

    要解析的json //解析前 //解析前 {,,,,,,,,,,},,,,,,,,,,,},,,,,,,,,,,,,,,,},,,,,,,,,},,,,,,,,,,,,},,,,,,,,,,,},,, ...