用kettle新建DB连接的时候总是报错,可是用plsql连接是可以连上,错误信息大致如下:
错误连接数据库 [MIS] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
10.9.202.67:1521:ORCL
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
10.9.202.67:1521:ORCL
at org.pentaho.di.core.database.Database.normalConnect(Database.java:312)
at org.pentaho.di.core.database.Database.connect(Database.java:261)
at org.pentaho.di.core.database.Database.connect(Database.java:223)
at org.pentaho.di.core.database.Database.connect(Database.java:213)
at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:55)
at org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2409)
at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:487)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:294)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:124)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:112)
at org.pentaho.ui.xul.swt.tags.SwtButton.access$000(SwtButton.java:17)
at org.pentaho.ui.xul.swt.tags.SwtButton$1.widgetSelected(SwtButton.java:77)
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:238)
at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:161)
at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:512)
at org.pentaho.di.ui.spoon.Spoon.newConnection(Spoon.java:6290)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.xul.EventHandler.handleMenuEvent(EventHandler.java:42)
at org.pentaho.xul.swt.menu.PopupMenu.handleMenuEvent(PopupMenu.java:40)
at org.pentaho.xul.swt.menu.MenuChoice.handleMenuEvent(MenuChoice.java:77)
at org.pentaho.xul.swt.menu.MenuChoice.handleEvent(MenuChoice.java:73)
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.pentaho.di.ui.repository.dialog.RepositoryExplorerDialog.open(RepositoryExplorerDialog.java:604)
at org.pentaho.di.ui.spoon.Spoon.exploreRepository(Spoon.java:2894)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.xul.EventHandler.handleMenuEvent(EventHandler.java:42)
at org.pentaho.xul.swt.menu.MenuBar.handleMenuEvent(MenuBar.java:52)
at org.pentaho.xul.swt.menu.Menu.handleMenuEvent(Menu.java:117)
at org.pentaho.xul.swt.menu.MenuChoice.handleMenuEvent(MenuChoice.java:77)
at org.pentaho.xul.swt.menu.MenuChoice.handleEvent(MenuChoice.java:73)
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.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:945)
at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:5574)
at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:412)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:116)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException:
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
10.9.202.67:1521:ORCL
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:435)
at org.pentaho.di.core.database.Database.normalConnect(Database.java:296)
... 61 more
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
10.9.202.67:1521:ORCL
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:430)
... 62 more
主机名 : 10.9.202.67
端口 : 1521
数据库名:ORCL
查找资料得知:
jdbc连接数据库的时候,需要使用数据库的sid_name,而不是数据库的services_name
而使用plsql连接数据库的时候,只需要数据库的services_name即可,所以修改连接字符串中的services_name (即连接参数中的database name)为sid_name
PS:查看数据库的sid_name语句:
select INSTANCE_NAME from v$instance;
转自:Kettle 连接失败 Oracle 数据库报 ora-12505 的解决方法(转) - 萨普洛斯小纯洁 - 博客园 (cnblogs.com)