File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Invoking a SQL and stored procedure" Watch "Invoking a SQL and stored procedure" New topic
Author

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..

package co.za.sarstces.payphone;

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++)
{

try{
csmt = connobj.prepareCall("{? = call so_util.wdpk_sms_messages.insert_sms(?,?,?,?,?,?,?,?,?,?,?,?,?) }");
//input parameters
// csmt.setInt(1, msisdnrange.[i]);
csmt.setString(2,messageContent);
csmt.setString(3,"");
csmt.setString(4,"");
csmt.setString(5,"");
csmt.setString(6,"");
csmt.setString(7,"");
csmt.setString(8,"");
csmt.setString(9,"");
csmt.setInt(10,10);
// csmt.registerOutParameter(11,NUMBER);;
// csmt.registerOutParameters(12,VARCHAR);

ResultSet rs =csmt.executeQuery();
csmt.close();

} catch (Exception e)
{

}
return null;

}
}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invoking a SQL and stored procedure
 
Similar Threads
Data insertion problem
struts help needed for error No getter method
msyql jdbc problem.
insert into method
Problem while creating Struts application