File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Invoking a SQL and stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Invoking a SQL and stored procedure" Watch "Invoking a SQL and stored procedure" New topic

Invoking a SQL and stored procedure

Kingsley Mullers
Ranch Hand

Joined: Jan 14, 2005
Posts: 48
Hi guys, i've written the following code and feed i've left out something , i just need to put it together correctly with a solid logic..can you help me put it nicely...i'm sending short messages (from s stored procedure)to the results generated from the SQL statement...thanking advance..


import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.Connection;
import org.apache.log4j.Logger;
public class GeographicalArea

private static StringBuffer sqlString = null;
private static String NumberList;
private Connection connobj;

public GeographicalArea(){ }

// public NumberList getAgentrange(Connection cn,String rangebegin, String rangeend)

// declare the resultset
PreparedStatement pstmt=null;
ResultSet rs =null;

sqlString = new StringBuffer();
sqlString.append(" select distinct ccp01_contact_msisdn ");
sqlString.append(" from so_cpp.tcp08_payphone_histories b , SO_CPP.TCP01_OWNER_DETAILS c ");
sqlString.append(" where b.ccp08_owner_id = c.ccp01_owner_id ");
sqlString.append(" and b.ccp08_msisdn between ? ");
sqlString.append(" and ? ");
sqlString.append(" and nvl(ccp01_contact_msisdn , 0) > 0");
sqlString.append(" and nvl(ccp08_date_ceased,sysdate+1) > sysdate ");

// pstmt = cn.prepareStatement(sqlString);
// rs = pstmt.executeQuery();

// return rs;


public String sendMSISDN(Connection connobj, int contactNumber, String messageContent)

GeographicalArea area = new GeographicalArea();
NumberRange getAgentsrange = new NumberRange();
// getAgentsrange = area.getAgentrange();
CallableStatement csmt = null;
// for(int i = 0; i < msisdnrange.size(); i++)

csmt = connobj.prepareCall("{? = call so_util.wdpk_sms_messages.insert_sms(?,?,?,?,?,?,?,?,?,?,?,?,?) }");
//input parameters
// csmt.setInt(1, msisdnrange.[i]);
// csmt.registerOutParameter(11,NUMBER);;
// csmt.registerOutParameters(12,VARCHAR);

ResultSet rs =csmt.executeQuery();

} catch (Exception e)

return null;


I agree. Here's the link:
subject: Invoking a SQL and stored procedure
It's not a secret anymore!