iversonmania
Sep 11th, 2009, 05:31 AM
package project1;
package project1;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Types;
public class runquery {
public static void main (String[] args) throws InterruptedException
{
Connection conn =null;
CallableStatement cs = null;
ResultSet rs = null;
int updateQuery = 0;
try
{
String url = "jdbc:oracle:thin:@ahmad:1521:ORCL";
String user = "training";
String password = "training";
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("--------------");
conn = DriverManager.getConnection(url, user, password);
}
catch(Exception ex)
{
System.out.println("Error in creating the connection :"+ex.getMessage());
}
try
{
cs = conn.prepareCall("{call inout_fn4(?)}");
cs.registerOutParameter(1, Types.VARCHAR);
cs.execute();
String outParam = cs.getString(1);
System.out.println(outParam);
}
catch (Exception exp)
{
System.out.println("Error in Query execution ");
}
}}
SET serveroutput ON
DECLARE
retval VARCHAR2(20);
ioval VARCHAR2(20) := 'Going in';
BEGIN
retval := inout_fn4(ioval);
END;
running this in toad gives me correct answer
but with java it gives me this
Error in Query execution
Process exited with exit code 0.
package project1;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Types;
public class runquery {
public static void main (String[] args) throws InterruptedException
{
Connection conn =null;
CallableStatement cs = null;
ResultSet rs = null;
int updateQuery = 0;
try
{
String url = "jdbc:oracle:thin:@ahmad:1521:ORCL";
String user = "training";
String password = "training";
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("--------------");
conn = DriverManager.getConnection(url, user, password);
}
catch(Exception ex)
{
System.out.println("Error in creating the connection :"+ex.getMessage());
}
try
{
cs = conn.prepareCall("{call inout_fn4(?)}");
cs.registerOutParameter(1, Types.VARCHAR);
cs.execute();
String outParam = cs.getString(1);
System.out.println(outParam);
}
catch (Exception exp)
{
System.out.println("Error in Query execution ");
}
}}
SET serveroutput ON
DECLARE
retval VARCHAR2(20);
ioval VARCHAR2(20) := 'Going in';
BEGIN
retval := inout_fn4(ioval);
END;
running this in toad gives me correct answer
but with java it gives me this
Error in Query execution
Process exited with exit code 0.