Trace IP address / machine of user logging in database with wrong password

on 3:19 AM

Enable audit in database with parameter AUDIT_TRAIL
SQL> show parameter audit_trail;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_trail                          string      DB_EXTENDED
 Enable session auditing
SQL> audit session;

Audit succeeded.
 Check DBA_AUDIT_TRAIL view:
SQL> select os_username, userhost, username, action_name, timestamp, returncode
  2  from dba_audit_trail
  3  where returncode=1017;

OS_USERNAME
--------------------------------------------------------------------------------
USERHOST
--------------------------------------------------------------------------------
USERNAME                       ACTION_NAME                  TIMESTAMP RETURNCODE
------------------------------ ---------------------------- --------- ----------
pierre
WORKGROUP\PC-de-pierre
HR                             LOGON                        22-FEB-11       1017
1017 stands for ORA-1017 Oracle error:
oerr ora 1017
01017, 00000, "invalid username/password; logon denied"
// *Cause:
// *Action:
OS_USERNAME is OS account name of user that is trying to connect to Oracle
USERHOST is the machine name where executable has tried to connect.

Connect to the Oracle database via JDBC

on 1:49 PM

For connecting Java application with the Oracle Database :

Driver class: The driver class for the oracle database is oracle.jdbc.driver.OracleDriver.
Connection URL: The connection URL for the oracle10G database is 

jdbc:oracle:thin:@localhost:1521:xe 


 jdbc : API, 

oracle : database, 
thin : driver, 
localhost : is the server name on which oracle is running, we may also use IP address, 
1521 : is the port number 
XE : is the Oracle service name. 

You may get all these informations from the tnsnames.ora file.


Username: The default username for the oracle database is system.

Password: Password is given by the user at the time of installing the oracle database.


In this example, system is the username and oracle is the password of the Oracle database.
  1. import java.sql.*;  
  2. class OracleCon{  
  3. public static void main(String args[]){  
  4. try{  
  5. //step1 load the driver class  
  6. Class.forName("oracle.jdbc.driver.OracleDriver");  
  7.   
  8. //step2 create  the connection object  
  9. Connection con=DriverManager.getConnection(  
  10. "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");  
  11.   
  12. //step3 create the statement object  
  13. Statement stmt=con.createStatement();  
  14.   
  15. //step4 execute query  
  16. ResultSet rs=stmt.executeQuery("select * from emp");  
  17. while(rs.next())  
  18. System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  
  19.   
  20. //step5 close the connection object  
  21. con.close();  
  22.   
  23. }catch(Exception e){ System.out.println(e);}  
  24.   
  25. }  
  26. }