简体   繁体   中英

Pentaho Kettle Invalid JNDI connection Could not create connection to database server

I was using JNDI method to connect several MySQL database servers with my Pentaho PDI (CE 5.0.1) and working fine till now, excpet the one. One of the MySQL server went down, so I changed my JNDI connection (...\\data-integration\\simple-jndi\\jdbc.properties) to connect to new server, but Kettle is not recogising this change and throwing the error as follows:

Error connecting to database [db-name] : org.pentaho.di.core.exception.KettleDatabaseException: Error occured while trying to connect to the database Invalid JNDI connection kidr_db_5 : Could not create connection to database server. Attempted reconnect 3 times. Giving up. org.pentaho.di.core.exception.KettleDatabaseException: Error occured while trying to connect to the database Invalid JNDI connection kidr_db_5 : Could not create connection to database server. Attempted reconnect 3 times. Giving up.

I can connect to new server directly from Kettle through Native(JDBC) connection method, but not through JNDI only for this new server. Rest DB connection from JNDI working fine. Please guide me whats wrong here? Am missing something? or is it a bug?

I had resolved this issue, sorry in replying lately. The problem was, the password included few special characters including # symbol; but in Pentaho, # is a comment line, so part of password was appeared to be comment for Pentaho.

So the conclusion is, don't use # other than comments in either JNDI configuration or Kettle configuration files.

Quick info. Not exactly it is a Kettle Pentaho bug. Bug(if it is not made intentionally) is in "simple-jndi" library. Library simple-jndi is used by Kettle, to provide jndi context. While oracle documentation of java.util.Properties class ( http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html ) states that, comment line must started by '#' symbol and it must be the first symbol in the line, library "simple-jndi" - use own loader, called org.osjava.sj.loader.util.CustomLoader . That is where bug resides

int idx = line.indexOf('#');
// remove comment
if(idx != -1) {
    line = line.substring(0,idx);
}

So comment is everything after '#' symbol in the line if u use simple-jndi.

use .xml instead of .properties

<?xml version="1.0" encoding="UTF-8"?>
<something>
 <connection-name>
  <type>javax.sql.DataSource</type>
  <driver>org.postgresql.Driver</driver>
  <url>jdbc:postgresql://localhost:5432/database</url>
  <user>user</user>
  <password>#secret#</password>
 </connection-name>
</something>

my files is called connections.xml and then you can refer to connections/something/connection-name in pdi for above example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM