Not able to connect to oracle database using JDBC if password is having special characters

前端 未结 2 581
猫巷女王i
猫巷女王i 2020-12-21 15:53

I am trying to connect to oracle database using JDBC.

following is the code::

public class OraclePwdTest {
static{
    try {           
        Clas         


        
2条回答
  •  粉色の甜心
    2020-12-21 16:57

    A simple code would looks like this... As you are using thin driver you don't need to complicate with all those values from tnsnames.ora.

            Class.forName("oracle.jdbc.OracleDriver");
            Properties properties = new Properties();
            properties.setProperty("user", username);
            properties.setProperty("password", password);
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@::, properties);
    

    ie. jdbc:oracle:thin:@192.168.20.145:1521:oradg

提交回复
热议问题