`
flylynne
  • 浏览: 362538 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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 时,如果遇到井号,会截取到井号前的内容该行后面的内容都将丢失、

 

源码

https://github.com/pentaho/pentaho-simple-jndi/blob/master/src/main/java/org/osjava/sj/loader/util/CustomProperties.java?spm=a2c4e.10696291.0.0.285519a43Efnes&file=CustomProperties.java

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics