使用Kettle报错的解决方法
1.当你在navicat上面测试数据库连接的时候可以看到数据库连接成功。而在Kettle上面连接同样的库的时候报出一大段错误出来,这时候是不是感觉有点懵逼了。
错误内容如下:
错误连接数据库 [test库] : com.tyky.di.core.exception.XbridgeDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
Connection setting too low for ‘maxAllowedPacket‘. When ‘useServerPrepStmts=true‘, ‘maxAllowedPacket‘ must be higher than 8203. Check also ‘max_allowed_packet‘ in MySQL configuration files.
com.tyky.di.core.exception.XbridgeDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
Connection setting too low for ‘maxAllowedPacket‘. When ‘useServerPrepStmts=true‘, ‘maxAllowedPacket‘ must be higher than 8203. Check also ‘max_allowed_packet‘ in MySQL configuration files.
at com.tyky.di.core.database.Database.normalConnect(Database.java:374)
at com.tyky.di.core.database.Database.connect(Database.java:323)
at com.tyky.di.core.database.Database.connect(Database.java:285)
at com.tyky.di.core.database.Database.connect(Database.java:275)
at com.tyky.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:76)
at com.tyky.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2455)
at com.tyky.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:511)
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 org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:329)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:139)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:123)
at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:26)
at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:119)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:378)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:304)
at com.tyky.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:104)
at com.tyky.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:51)
at com.tyky.di.ui.spoon.delegates.SpoonDBDelegate.editConnection(SpoonDBDelegate.java:78)
at com.tyky.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:3010)
at com.tyky.di.ui.spoon.Spoon.access$19(Spoon.java:2974)
at com.tyky.di.ui.spoon.Spoon$23.widgetDefaultSelected(Spoon.java:5960)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.tyky.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1259)
at com.tyky.di.ui.spoon.Spoon.start(Spoon.java:7896)
at com.tyky.di.ui.spoon.Spoon.main(Spoon.java:582)
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 org.pentaho.commons.launcher.Launcher.main(Launcher.java:134)
Caused by: com.tyky.di.core.exception.XbridgeDatabaseException:
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
Connection setting too low for ‘maxAllowedPacket‘. When ‘useServerPrepStmts=true‘, ‘maxAllowedPacket‘ must be higher than 8203. Check also ‘max_allowed_packet‘ in MySQL configuration files.
at com.tyky.di.core.database.Database.connectUsingClass(Database.java:510)
at com.tyky.di.core.database.Database.normalConnect(Database.java:358)
... 43 more
Caused by: java.sql.SQLException: Connection setting too low for ‘maxAllowedPacket‘. When ‘useServerPrepStmts=true‘, ‘maxAllowedPacket‘ must be higher than 8203. Check also ‘max_allowed_packet‘ in MySQL configuration files.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3305)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2278)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
at sun.reflect.GeneratedConstructorAccessor32.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:377)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at com.tyky.di.core.database.Database.connectUsingClass(Database.java:490)
... 44 more
主机名 : 172.16.200.12
端口 : 3306
数据库名:test
2.解决办法:该错误由所连数据库中的max_allowed_packet字段引起,查询所连接数据库的该字段将字段大小设置更大问题解决。修改max_allowed_packet字段大小有两种方法,具体如下:
方法1:用语句设置,但是这种情况可能会出现mysql重启后所设置的值失效。
show VARIABLES like ‘%max_allowed_packet%‘;
set global max_allowed_packet = 1024*1024
2.1方法2:在数据库下my.ini文件中添加如下语句。将max_allowed_packet改为1G.如下图所示。修改完成后,需要重启mysql。
---------------------
作者:装会逼
来源:CSDN
原文:https://blog.csdn.net/spcsdn_18785143187/article/details/81133016
版权声明:本文为博主原创文章,转载请附上博文链接!
原文地址:https://www.cnblogs.com/LXL616/p/10822833.html