连接到数据库时出错:(使用类org.gjt.mm.mysql.Driver)

时间:2015-02-21 12:38:48

标签: mysql pentaho

我正在尝试在Pentaho 5.3.0.0-213中建立与localhost上的mysql的连接。我正在使用运行OS 10.10.2的Mac。我可以使用Sequel Pro连接到数据库并阅读本网站上已经给出的所有答案(以及其他人!)并将mysql-connector-java-5.1.34-bin.jar下载并复制到data-integration / lib仍然得到同样的错误。

欢迎任何建议。

整个错误消息如下: 连接到数据库[localhost_con]时出错:org.pentaho.di.core.exception.KettleDatabaseException: 尝试连接数据库时发生错误

连接数据库时出错:(使用类org.gjt.mm.mysql.Driver) 通信链路故障

成功发送到服务器的最后一个数据包是0毫秒前。驱动程序未收到来自服务器的任何数据包。

org.pentaho.di.core.exception.KettleDatabaseException: 尝试连接数据库时发生错误

连接数据库时出错:(使用类org.gjt.mm.mysql.Driver) 通信链路故障

成功发送到服务器的最后一个数据包是0毫秒前。驱动程序未收到来自服务器的任何数据包。

    at org.pentaho.di.core.database.Database.normalConnect(Database.java:417)
    at org.pentaho.di.core.database.Database.connect(Database.java:357)
    at org.pentaho.di.core.database.Database.connect(Database.java:310)
    at org.pentaho.di.core.database.Database.connect(Database.java:300)
    at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:80)
    at org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2685)
    at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:546)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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:138)
    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.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.notifyListeners(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:389)
    at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:318)
    at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:116)
    at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:59)
    at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.editConnection(SpoonDBDelegate.java:87)
    at org.pentaho.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:3096)
    at org.pentaho.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:3031)
    at org.pentaho.di.ui.spoon.Spoon.access$2400(Spoon.java:347)
    at org.pentaho.di.ui.spoon.Spoon$27.widgetDefaultSelected(Spoon.java:6121)
    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.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.notifyListeners(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:1316)
    at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7979)
    at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9310)
    at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:654)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
    at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
    at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:561)
    at org.pentaho.di.core.database.Database.normalConnect(Database.java:400)
    ... 60 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1036)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:338)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2232)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
    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.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    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:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:543)
    ... 61 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:382)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:241)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:228)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:431)
    at java.net.Socket.connect(Socket.java:527)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:213)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:297)
    ... 76 more

主机名:localhost 港口:3306 数据库名称:my_learning_sql

3 个答案:

答案 0 :(得分:1)

我已经看到了这个问题,具体取决于数据库的版本和MySQL驱动程序的版本。我正在使用mysql-connector-java-5.1.17.jar并且必须升级到mysql-connector-java-5.1.34-bin.jar以便让我的工作。也许你的问题是相反的问题,你可以将你的驱动程序降级到mysql-connector-java-5.1.17.jar来修复你的问题吗?

答案 1 :(得分:0)

我遇到了类似的问题(上面列出的驱动程序,操作系统等相同的版本),最后跟踪到这一点:我的~/.kettle/kettle.properties文件没有列出数据库主机设置的方式与变换中列出的数据库连接的方式相同。

deweygarwood$ cat ~/.kettle/kettle.properties 
# This file was generated by Pentaho Data Integration version 5.1.2.1.
... stuff here

DW_HOST=localhost <~~~ this line
DW_DBPORT=3306
DW_DBNAME=datawarehouse
DW_DBUSER=root
DW_DBPASSWORD=

与水壶变换中的数据库连接中列出的名称不匹配,即${DW_DBHOST}

我发现这个的方式是使用&#34;测试&#34;数据库连接屏幕上的按钮并滚动到底部。输出显示变量&#34; $ {DW_DBHOST}&#34;而不是&#34; localhost&#34;。更新我的~/.kettle/kettle.properties文件以使用相同的变量名解决了这个问题。

假设您正在使用kettle.properties进行连接设置,我预计会出现类似的情况。

答案 2 :(得分:0)

  1. 从此处下载Mysql连接器:connector
  2. 解压缩文件
  3. 仅将两个* .jar文件复制到data-integration / lib /
  4. 重新启动Pentaho
  5. 转到:数据库连接->选择MySql->编辑您的连接信息->测试连接。

这些步骤解决了我的问题。