Kettle-JNDI模式-密码错误
package org.osjava.sj.loader.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class CustomProperties extends AbstractProperties {
public synchronized void load(InputStream in) throws IOException {
try {
BufferedReader reader = new BufferedReader( new InputStreamReader(in) );
String line = "";
String nextLine = null;
while( (line = reader.readLine()) != null) {
// we may already be on a multi-line statement.
if(nextLine != null) {
line = nextLine + line;
nextLine = null;
}
line = line.trim();
if(line.endsWith("\\")) {
nextLine = line;
continue;
}
int idx = line.indexOf('#');
// remove comment
if(idx != -1) {
line = line.substring(0,idx);
}
// split equals sign
idx = line.indexOf('=');
if(idx != -1) {
this.setProperty(line.substring(0,idx), line.substring(idx+1));
} else {
// blank line, or just a bad line
// we ignore it
}
}
reader.close();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
}
Kettle连接,使用OCI连接正常,但采用JNDI总是报账户密码不正确,原因是密码里面包含了#
我们通过配置 jdbc.properties 来使用 JNDI 模式连接数据库;
这次我们的密码是OA_R/password=A#123User
因为Kettle在解析 jdbc.properties 时,如果遇到井号,会截取到井号前的内容该行后面的内容都将丢失、
源码