not able to hit the database through java program


I am running follwoing java program to select, insert values into oracle 10g dfatabase table through RAD workspace.

import java.sql.*;

class dbtest {

 public static void main(String args[])   throws
ClassNotFoundException, SQLException {


   // or you can use:

   // DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

   Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","deliverytest7","dbpasword");

   Statement stmt = conn.createStatement();

   ResultSet rset = stmt.executeQuery("select * from stud");











It gives error message like invalid user name and password. I am able to connect to same schema through sql plus without any issues. Please advise. Any links, ideas, resources highly appreciated. Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Please show how you connect via sqlplus.

sqlplus deliverytest7/dbpasword

>>I am able to connect to same schema through sql plus without any issues.

There's got to be something different. Are you sure it's not a different copy of the db?
I agree with Charles. Invalid username/password error means you hit the instance.

That is why I want to see the explicit command used to connect via sqlplus.

Are there different dbs on the same box?

Also show:  lsnrctl services
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

gudii9Author Commented:
It is same copy of database schema i am hitting. I am able to connect using sqldeveloper also as in screenshot similar to sqlplus.
That is fine, but please answer the specific questions above.

Oracle JDBC service name syntax requires a / in the JDBC URL nowadays. Your JDBC URL is using SID syntax (which is ok, but I am just pointing out the difference), yet your SQL Developer connection is using service syntax. Please try the SID option, or use sqlplus.

sqlplus user/pass@orcl

Again, how many databases are on your system?
May be sillypoint.. but still wants to point out. Password is:
dbpasword     OR     dbpassword           (i.e. double ss).

Show the : sqlplus user/pass@orcl             result as pointed out by mrjoltcola.

gudii9Author Commented:
I only have one database running in my laptop with xp OS. Sqlplus i am not connecting through command prompt but from

start-->all programs--->oracle oracle 10g--->sqlplus etc as in screnshot.

How shall i change following statement to include service name instead of SID

Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","deliverytest7","dbpasword");

Please advise
gudii9Author Commented:
through command prompt also i was able to connect as in screenshot
gudii9Author Commented:
screenshot is like this
I don't understand why it is so difficult for you to follow my explicit directions above?

The reason I am asking you to connect with the _explicit_ syntax is to force the use of the TNS alias, if it exists. You've also not provided the output to the info asked for in:  http:#24774308

So, one last time, please try:

1) sqlplus deliverytest8/passwordxxx@orcl

2) Also show output of: lsnrctl services

From the posted screenshot, from the password field I can see 10 masked stars. So, I guess the correct password is 'dbpassword'(10 digits) and not 'dbpasword' (9 digits).

Can you post the EXACT output of the following commands.

1. sqlplus deliverytest7/dbpasword

2. sqlplus deliverytest7/dbpassword

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gudii9Author Commented:
thank you very much for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.