在阿里雲RDS新建庫和用戶,並分配權限,並且用客戶端訪問鏈接成功。但啓動應用,並修改鏈接用戶和庫地址,報錯(信息以下)!java
字面意思是用戶沒有SELECT的權限,但客戶端驗證不是權限問題。mysql
經多步測試發現應用一直在訪問同一個數據庫,並且名稱相同,一直是「A」,最後找到問題真正緣由,原來是這個註解的問題,catalog指定數據庫名稱,就會一直訪問這個數據庫名,但願你們引覺得介。(catalog用法詳見「附錄」)
spring
@Entity @Table(name = "t_activity", catalog = "")
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user 'huospk_jifen'@'10.151.132.48' for table 't_leitai' at sun.reflect.GeneratedConstructorAccessor51.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2818) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2157) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2324) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
附錄 注:sql
Table Table用來定義entity主表的name,catalog,schema等屬性。 元數據屬性說明: name: 表名 catalog: 對應關係數據庫中的catalog,若是在entitybean中設置此屬性,將在表名前面加上catalog指定的值,注意catalog的值必定是數據庫的名稱,否則會生成的sql語句回報找不到表的錯誤。 schema:對應關係數據庫中的schema UniqueConstraints:定義一個UniqueConstraint數組,指定須要建惟一約束的列 @Entity @Table(name="CUST") public class Customer { ... }
參照:數據庫
JPA註解 catalog
數組
http://blog.csdn.net/yangqicong/article/details/6906284測試