procedure call from netbeans

View: New views
3 Messages — Rating Filter:   Alert me  

procedure call from netbeans

by ankur572 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hiiiiii

               i write a function for login when i write this code then it is not working



   java.lang.String sql="{call login_action(?,?)}";

    java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

    java.sql.Connection cn=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "matrix");

    java.sql.CallableStatement cs=cn.prepareCall(sql);

    System.out.println(cn+" "+user+pass);

    cs.setString(1, user);

    cs.setString(2, pass);

    java.sql.ResultSet rs = cs.executeQuery();

    while(rs.next())

    {

        System.out.println(rs.getString(1));

    }





while this code is working--------------

java.lang.String sql="select login_action(?,?) from dual";

    java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

    java.sql.Connection cn=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "matrix");

    java.sql.CallableStatement cs=cn.prepareCall(sql);

    System.out.println(cn+" "+user+pass);

    cs.setString(1, user);

    cs.setString(2, pass);

    java.sql.ResultSet rs = cs.executeQuery();

    while(rs.next())

    {

        System.out.println(rs.getString(1));

    }





difference is only bold text part...............can you please tell me the exact way to call oracle function from java.......or any other way within netbeans .............or any specific driver that needed...........whatever

i will appreciate your reply...................................................                                                                               thank you.................





Re: procedure call from netbeans

by Gregg Wonderly-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is the SQLException that you are getting?  That should tell you exactly
what the problem is.

Gregg Wonderly

ankur572 wrote:

> hiiiiii
>
>                i write a function for login when i write this code then it is not working
>
>
>
>    java.lang.String sql="{call login_action(?,?)}";
>
>     java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
>
>     java.sql.Connection cn=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "matrix");
>
>     java.sql.CallableStatement cs=cn.prepareCall(sql);
>
>     System.out.println(cn+" "+user+pass);
>
>     cs.setString(1, user);
>
>     cs.setString(2, pass);
>
>     java.sql.ResultSet rs = cs.executeQuery();
>
>     while(rs.next())
>
>     {
>
>         System.out.println(rs.getString(1));
>
>     }
>
>
>
>
>
> while this code is working--------------
>
> java.lang.String sql="select login_action(?,?) from dual";
>
>     java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
>
>     java.sql.Connection cn=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "matrix");
>
>     java.sql.CallableStatement cs=cn.prepareCall(sql);
>
>     System.out.println(cn+" "+user+pass);
>
>     cs.setString(1, user);
>
>     cs.setString(2, pass);
>
>     java.sql.ResultSet rs = cs.executeQuery();
>
>     while(rs.next())
>
>     {
>
>         System.out.println(rs.getString(1));
>
>     }
>
>
>
>
>
> difference is only bold text part...............can you please tell me the exact way to call oracle function from java.......or any other way within netbeans .............or any specific driver that needed...........whatever
>
> i will appreciate your reply...................................................                                                                               thank you.................
>
>
>
>
>
>


procedure call from netbeans

by ankur572 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SQLException is that

login_action is not a procedure or undefined function