FAQ- java.sql.SQLException:Connection is read-only

问题描述/异常栈
23/06/29 09:22:29 ERROR ApplicationMaster: User class threw exception: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed. java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861) at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:760) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:729) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.mysql.jdbc.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:108) at com.mysql.jdbc.FailoverConnectionProxy$FailoverJdbcInterfaceProxy.invoke(FailoverConnectionProxy.java:95) at com.sun.proxy.$Proxy38.execute(Unknown Source) at com.netease.music.da.transfer.jdbc.connection.DBConnection.executeQuery(DBConnection.scala:55) at com.netease.music.da.transfer.jdbc.util.TransferJdbcDialect.executeChangeDbSql(TransferJdbcDialect.scala:22) at com.netease.da.music.transfer.doris.jdbc.DorisTransferJdbcDialect.changeDatabase(DorisTransferJdbcDialect.scala:10) at com.netease.music.da.transfer.jdbc.connection.SQLExecutor.changeDatabase(SQLExecutor.scala:21) at com.netease.music.da.transfer.jdbc.connection.SQLExecutor.doPreSQL(SQLExecutor.scala:27) at com.netease.da.music.transfer.starrocks.writer.StarrocksWriter.doWrite(StarrocksWriter.scala:20) at com.netease.music.da.transfer.common.writer.AbstractDataWriter.write(AbstractDataWriter.scala:16) at com.netease.music.da.transfer.common.Worker$.main(Worker.scala:96) at com.netease.music.da.transfer.common.Worker.main(Worker.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:678)
发现版本
starrocks 1.19
解决方案
任务卡在use database时,登记成mysql数据源use正常,starrocks 无权限,需找DBA确认,
临时方案设置target.useDatabase=false
问题原因
无权限切换数据库 FAQ- java.sql.SQLException:Connection is read-only - 图1

作者:林帅