2 Replies Latest reply: Apr 28, 2013 6:28 AM by Hoek RSS

    Oracle and Java


      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
          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: http://docs.oracle.com/cd/E11882_01/appdev.112/e12137/toc.htm

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

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