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`)));
存储过程也是一样的,往往就会忽略这个问题而导致上面的错误.