user396070
user396070

Reputation:

Why can't IntelliJ find the db user credentials when working with local data source?

I have added and can work with my production data source with no problems, but I'm having issues working with a second "local" data source. My connection settings look something like this:

Database URL: jdbc:mysql://localhost:3306/<database_name>

User: <username>

Password: <password>

Testing the connection succeeds and I can see a list of the tables, but can't read contents of tables. Yes, this user has full access to the db in question; I confirmed this in MySQL Workbench. The problem appears to be specific to IntelliJ-IDEA.

IntelliJ-IDEA complains thusly:

java.sql.SQLException: SELECT command denied to user ''@'%' for column 'mycolumn'

Notice user is ''@'%' in the error message. What is going wrong?

Again, testing the connection succeeds and I can see a list of the tables and the aforementioned user works just fine in MySQL Workbench (can select/update/insert all tables).

I'm running IntelliJ-IDEA version 12.1.4.

screenshot of error message

Entire connection error:

database_name.*
java.sql.SQLException: SELECT command denied to user ''@'%' for column 'column_name' in      table 'table_name'
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at     sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  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:2812)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)
  at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
  at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2571)
  at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2458)
  at com.mysql.jdbc.IterateBlock.doForAll(IterateBlock.java:51)
  at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:2457)
  at   com.intellij.persistence.jdbc.impl.RemoteDatabaseMetaDataImpl.getColumns(RemoteDatabaseMetaDataImpl.java:170)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
  at sun.rmi.transport.Transport$1.run(Transport.java:177)
  at sun.rmi.transport.Transport$1.run(Transport.java:174)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
  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:724)
  at   sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
  at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
  at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
  at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
  at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
  at com.sun.proxy.$Proxy147.getColumns(Unknown Source)
  at sun.reflect.GeneratedMethodAccessor398.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.execution.rmi.RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:211)
  at com.sun.proxy.$Proxy148.getColumns(Unknown Source)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadTableBasicsInner(DatabaseSchemaLoader.java:998)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadTableBasics(DatabaseSchemaLoader.java:961)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadElementDetails(DatabaseSchemaLoader.java:891)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadDataSourceState(DatabaseSchemaLoader.java:113)
  at com.intellij.javaee.dataSource.AbstractDataSource.refreshMetaData(AbstractDataSource.java:49)
  at com.intellij.javaee.dataSource.AbstractDataSource$1.perform(AbstractDataSource.java:27)
  at com.intellij.javaee.dataSource.AbstractDataSource$1.perform(AbstractDataSource.java:25)
  at com.intellij.javaee.dataSource.DataSource.performJdbcOperation(DataSource.java:296)
  at com.intellij.javaee.dataSource.AbstractDataSource.refreshMetaData(AbstractDataSource.java:25)
  at com.intellij.javaee.module.view.dataSource.DataSourceUiUtil$2.run(DataSourceUiUtil.java:120)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:495)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:400)
  at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  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:724)
  at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)

Upvotes: 2

Views: 1935

Answers (1)

user396070
user396070

Reputation:

I had a view. As suggested by another post (credit: @FooBarUser), I changed the view's 'DEFINER' to a valid local user and the problem was solved!

Upvotes: 2

Related Questions