This discussion is archived
2 Replies Latest reply: Apr 28, 2013 4:28 AM by Hoek RSS

Oracle and Java

1005943 Newbie
Currently Being Moderated

How can I write a query in Java to retrieve data from Oracle database, if I want to put some parameters from my Java application in that query?
For example:

String username = userName.getText().toString();
String pass = password.getText().toString();
String command = "SELECT UserName, Password FROM Users WHERE UserName='username' and Password = 'password'";

So how do I put strings username and password into this query?

In c# and I do it like this:

SqlCommand cmd = new SqlCommand("SELECT * from korisnici where korisnicko_ime = @korisnicko_ime2 and lozinka = @lozinka2", con);
cmd.Parameters.AddWithValue("korisnicko_ime2", kor_ime.Text);
cmd.Parameters.AddWithValue("lozinka2", lozinka.Text);
dr = cmd.ExecuteReader();

Where can I find some materials to learn more about this?
  • 1. Re: Oracle and Java
    Hoek Guru
    Currently Being Moderated
    Welcome to the SQL and PL/SQL Forum.
    I guess you're better off in the Forums under
    and/or see the Java Developer's Guide:

    Edited by: Hoek on Apr 28, 2013 1:27 PM
  • 2. Re: Oracle and Java
    1005943 Newbie
    Currently Being Moderated
    I solved my problem now but I will check this links.

    Edited by: 1002940 on Apr 28, 2013 4:29 AM


  • Correct Answers - 10 points
  • Helpful Answers - 5 points