1.0前言

配置kettle 的spoon需要进行相关操作的时候,发现怎么也连不上,开始时第一反应是数据库的问题(我用的是服务器上的数据库),换了本地数据库去连接发现还是一样的错误:

2.0报错

错误连接数据库 [kettle] : org.pentaho.di.core.exception.KettleDatabaseException: 
Error occurred while trying to connect to the database

Driver class 'org.gjt.mm.mysql.Driver' could not be found, make sure the 'MySQL' driver (jar file) is installed.
org.gjt.mm.mysql.Driver


org.pentaho.di.core.exception.KettleDatabaseException: 
Error occurred while trying to connect to the database

Driver class 'org.gjt.mm.mysql.Driver' could not be found, make sure the 'MySQL' driver (jar file) is installed.
org.gjt.mm.mysql.Driver


	at org.pentaho.di.core.database.Database.normalConnect(Database.java:477)
	at org.pentaho.di.core.database.Database.connect(Database.java:373)
	at org.pentaho.di.core.database.Database.connect(Database.java:344)
	at org.pentaho.di.core.database.Database.connect(Database.java:334)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:83)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestResults(DatabaseFactory.java:112)
	at org.pentaho.di.core.database.DatabaseMeta.testConnectionSuccess(DatabaseMeta.java:2843)
	at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:631)
	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.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:313)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:157)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:141)
	at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:43)
	at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:137)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.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.di.ui.xul.KettleDialog.show(KettleDialog.java:89)
	at org.pentaho.di.ui.xul.KettleDialog.show(KettleDialog.java:56)
	at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:117)
	at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:61)
	at org.pentaho.di.ui.trans.step.BaseStepDialog.showDbDialogUnlessCancelledOrValid(BaseStepDialog.java:808)
	at org.pentaho.di.ui.trans.step.BaseStepDialog$AddConnectionListener.widgetSelected(BaseStepDialog.java:1487)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.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.pentaho.di.ui.trans.steps.tableinput.TableInputDialog.open(TableInputDialog.java:436)
	at org.pentaho.di.ui.spoon.delegates.SpoonStepsDelegate.editStep(SpoonStepsDelegate.java:120)
	at org.pentaho.di.ui.spoon.Spoon.editStep(Spoon.java:8814)
	at org.pentaho.di.ui.spoon.trans.TransGraph.editStep(TransGraph.java:3287)
	at org.pentaho.di.ui.spoon.trans.TransGraph.mouseDoubleClick(TransGraph.java:785)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.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.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1384)
	at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7949)
	at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9331)
	at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:710)
	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.pentaho.commons.launcher.Launcher.main(Launcher.java:92)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 
Driver class 'org.gjt.mm.mysql.Driver' could not be found, make sure the 'MySQL' driver (jar file) is installed.
org.gjt.mm.mysql.Driver

	at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:520)
	at org.pentaho.di.core.database.Database.normalConnect(Database.java:461)
	... 56 more
Caused by: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:495)
	... 57 more

3.0解决方案

这个问题是因为kettle连接mysql数据库的时候要通过mysql驱动包进行连接

  1. 首先进入官网去下载:进入官网中选择DOWNLOADS(下载)
  2. 进入跳转的页面后页面往下翻选择`MySQL Community (GPL) Downloads »`
  3. 选择`Connector/J` J指的是java
  4. 接下来再选择操作系统,此处选择platform independent(独立于平台),选择第二个下载
  5. 当点击下载上的时候MySQL官网会提醒你注册MySQL账号,不过不用注册一样下载,点击`No thanks, just start my download.`
  6. 将下载好的包解压,选中`mysql-connector-java-x.x.xx.jar`拖到kettle安装目录下的`/data-integration/lib/`目录中
  7. 接下来重启spoon再试一遍就能成功连接了

 

后记

官网的一般都是最新版的,大家想找自己mysql对应版本的话可以去这里寻找:

https://mvnrepository.com/artifact/mysql/mysql-connector-java