aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied" Watch "java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied" New topic
Author

java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied

lalit khera
Ranch Hand

Joined: Jun 06, 2012
Posts: 36
Please a look at this code, i am getting the error.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class InsertRecord {

public static void main(String[] args) {

String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String cs="jdbcdbc:siva";
String user = "siva";
String pwd = "siva";
String sqlstmt="INSERT INTO employee VALUES(1,'Steve',5,70)";
Connection con = null;
Statement st = null;
try
{
Class.forName(driver);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println("Driver loaded");
try
{
con=DriverManager.getConnection(cs,user,pwd);
System.out.println("Connected to the Oracle Database");
st = con.createStatement();//creates a Statement object for sending SQL statements to the database.
int updatecount=st.executeUpdate(sqlstmt);//return either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
System.out.println(updatecount+" row inserted");
}
catch(Exception e)
{
System.out.println(e);
}
try
{
st.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}//main()
}//class()



output is like:

Driver loaded
java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied
java.lang.NullPointerException


I am 100% sure that my username and password are siva and siva resp.
please help
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Don't use ODBC, if you're connecting to Oracle database. Use Oracle's type 4 JDBC driver (this page has a word or two on Oracle's drivers).

Can you verify using sqlplus that the password and username is correct? If you can, it is possible that the ODBC data source actually points to another database that you think it does.
lalit khera
Ranch Hand

Joined: Jun 06, 2012
Posts: 36
Martin Vajsar wrote:Don't use ODBC, if you're connecting to Oracle database. Use Oracle's type 4 JDBC driver (this page has a word or two on Oracle's drivers).

Can you verify using sqlplus that the password and username is correct? If you can, it is possible that the ODBC data source actually points to another database that you think it does.


Hi martin , that problem was resolved.
Actually i have used sql developer for creating and maintaining my database named siva.
I have also used the same name for connection name, username, password.
But strangely the user siva that i have created using sql developer is not reflecting in the Oracle EM.
I dont know why, but once i re-create the user and the schema using Oracle EM, everything becomes fine.
Could you help me by providing few good links/tutorials where i can learn these oracle jdbc issues.
Do i need to use commit for reflecting the username that i have created using SQL developer to the oracle EM??

thnks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied