I am trying to connect to oracle database using JDBC.
following is the code::
public class OraclePwdTest {
static{
try {
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String ip ="192.168.20.145";
String sid = "oradg";
int port = 1521;
String user = "sys";
String pwd = "s@novi123";
Connection conn = null;
String url = "jdbc:oracle:thin:"+"(DESCRIPTION =" +
"(ADDRESS_LIST =" +
"(ADDRESS = (PROTOCOL = TCP)(HOST = "+ ip +")" +
"(PORT = " + port + "))" +
")" +
"(CONNECT_DATA = (SRVR=DEDICATED) " +
"(SID = " + sid +
"))" +
")";
java.util.Properties prop = new java.util.Properties ();
prop.put ("user", user);
prop.put ("password", pwd);
prop.put ("internal_logon", "sysdba");
try {
conn = DriverManager.getConnection(url,prop);
System.out.println("Connected");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
If password is having special character like #@...then above code does not work. It works with plain password.
I get following error message ::
java.sql.SQLException: ORA-01017: invalid username/password; logon denied
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:573)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at TestOracleConnection.main(TestOracleConnection.java:54)
Please help me to resolve the issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…