📄 jdbcquery.java
字号:
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
return strRet;
}
/***************************************************************************
* @函数名称: ExecuteFunc
* @函数用途: 执行存储函数
* @参数列表: nIndex[参数的序号] strPara[参数值.都用String]
* @注意事项: 重载本函数是为给hibernate中调用存储过程提供便利
**************************************************************************/
// public String ExecuteOracleSetProc(Connection con, String strProcName,
// ArrayList listPara) throws SQLException
// {
// String strRet = "";
// CallableStatement toesUp = null;
// try
// {
// toesUp = con.prepareCall("{call INetSender.getTest2(?,?)}");
// toesUp.setInt(1, 0);
//
//
//
// //toesUp.registerOutParameter(2, OracleTypes.PLSQL_INDEX_TABLE);
// toesUp.registerOutParameter(2, OracleTypes.CURSOR);
// //toesUp.registerOutParameter(1, Types.OTHER);
// toesUp.execute();
//
// ResultSet rs = (ResultSet) toesUp.getObject(2);
//
// while (rs.next())
// {
// String name = rs.getString(1);
// System.out.println("name=" + name);
// }
// rs.close();
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
//
// return strRet;
// }
// public void ExecuteOracleSetProc(String strProcName,
// ArrayList listPara) throws SQLException
// {
// String strSQL = "";
// Connection con = null;
// CallableStatement proc = null;
//
// try
// {
// strSQL = "{call " + strProcName + "(";
// //toesUp = con.prepareCall("");
// for (int i = 0; i < listPara.size(); i++)
// {
// if (i < listPara.size() - 1)
// {
// strSQL = strSQL + "?,";
// }
// else
// {
// strSQL = strSQL + "?";
// }
// }
// strSQL += ")}";
//
//
// con = getConnection();
// if (con != null)
// {
// proc = con.prepareCall(strSQL);
//
// for (int i = 0; i < listPara.size(); i++)
// {
// String strPara = (String) listPara.get(i);
// proc.setString(i + 1, strPara);
// }
//
// proc.execute();
// }
//
//
// toesUp.setInt(1, 0);
//
// //toesUp.registerOutParameter(2, OracleTypes.PLSQL_INDEX_TABLE);
// toesUp.registerOutParameter(2, OracleTypes.CURSOR);
// //toesUp.registerOutParameter(1, Types.OTHER);
// toesUp.execute();
//
// ResultSet rs = (ResultSet) toesUp.getObject(2);
//
// while (rs.next())
// {
// String name = rs.getString(1);
// System.out.println("name=" + name);
// }
// rs.close();
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
//
//// 生成执行存储过程所需要的SQL语句
//
//
// //设置SQL语句
//
//
// //执行存储过程
// try
// {
//
//
// }
// finally
// {
// try
// {
// proc.close();
// }
// catch (SQLException e)
// {
// e.printStackTrace();
// }
//
// try
// {
// con.close();
// }
// catch (SQLException e)
// {
// e.printStackTrace();
// }
// }
// }
/***************************************************************************
* @函数名称: Bof()
* @函数用途: 是否结果集first()
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean Bof()
{
boolean boolRet = false;
if (set_m != null)
{
try
{
if (set_m.isBeforeFirst())
{
boolRet = true;
}
}
catch (Exception e)
{
}
}
return boolRet;
}
/***************************************************************************
* @函数名称: Eof()
* @函数用途: 是否结果集last()
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean Eof()
{
boolean boolRet = true;
if (set_m != null)
{
try
{
if (!set_m.isAfterLast())
{
boolRet = false;
}
}
catch (Exception e)
{
}
}
return boolRet;
}
/***************************************************************************
* @函数名称: RowCount()
* @函数用途: 集合的行个数
* @参数列表:
* @注意事项:
**************************************************************************/
public int RowCount()
{
int nRet = 0;
try
{
nRet = set_m.size();
}
catch (Exception e)
{
}
return nRet;
}
/***************************************************************************
* @函数名称: Next()
* @函数用途: 结果集向下移动
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean Next()
{
boolean boolRet = false;
try
{
set_m.next();
if (!Eof())
{
boolRet = true;
}
}
catch (Exception e)
{
}
return boolRet;
}
/***************************************************************************
* @函数名称: Prior()
* @函数用途: 结果集向上移动
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean Prior()
{
boolean boolRet = false;
try
{
set_m.previous();
if (!Bof())
{
boolRet = true;
}
}
catch (Exception e)
{
}
return boolRet;
}
/***************************************************************************
* @函数名称: First()
* @函数用途: 结果集移动到顶端
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean First()
{
boolean boolRet = false;
try
{
set_m.first();
boolRet = true;
}
catch (Exception e)
{
}
return boolRet;
}
/***************************************************************************
* @函数名称: Last()
* @函数用途: 结果集移动到底端
* @参数列表:
* @注意事项:
**************************************************************************/
public boolean Last()
{
boolean boolRet = false;
try
{
set_m.last();
boolRet = true;
}
catch (Exception e)
{
}
return boolRet;
}
/***************************************************************************
* @throws SQLException
* @函数名称: getRetString()
* @函数用途: 获取结果集合中名字为strFieldName的值
* @参数列表: strFieldName结果集的字段名
* @注意事项:
**************************************************************************/
public String getRetString(String strFieldName) throws SQLException
{
String strRet = set_m.getString(strFieldName);
return strRet;
}
/****************************************************************************
* @throws SQLException
* @函数名称: getRetInt
* @函数用途: 获取结果集中的结果,取整形
* @参数列表:
* @注意事项:
***************************************************************************/
public int getRetInt(String strFieldName) throws SQLException
{
int nRet = 0;
String strRet = set_m.getString(strFieldName);
nRet = Integer.parseInt(strRet);
return nRet;
}
/****************************************************************************
* @throws SQLException
* @函数名称: getRetFloat
* @函数用途: 获取
* @参数列表:
* @注意事项:
***************************************************************************/
public float getRetFloat(String strFieldName) throws SQLException
{
String strRet = set_m.getString(strFieldName);
float fltRet = Float.parseFloat(strRet);
return fltRet;
}
/****************************************************************************
* @函数名称: getRetDate
* @函数用途: 获取Date型的结果值
* @参数列表:
* @注意事项:
***************************************************************************/
public Timestamp getRetDate(String strFieldName) throws SQLException
{
String strRet = set_m.getString(strFieldName);
Timestamp tsRet = Timestamp.valueOf(strRet);
return tsRet;
}
/***************************************************************************
* @throws SQLException
* @函数名称: getStringFields
* @函数用途: 用字段序号获取结果值.
* @参数列表: nIndex:结果集中的序号
* @注意事项:
**************************************************************************/
public String getStringFields(int nIndex) throws SQLException
{
String strRet = set_m.getString(nIndex);
return strRet;
}
/****************************************************************************
* @throws SQLException
* @函数名称: getIntFields
* @函数用途: 读取整形的field
* @参数列表:
* @注意事项:
***************************************************************************/
public int getIntFields(int nIndex) throws SQLException
{
String strRet = set_m.getString(nIndex);
int nRet = Integer.parseInt(strRet);
return nRet;
}
/****************************************************************************
* @throws SQLException
* @函数名称: getFloatFields
* @函数用途: 获取float形的field
* @参数列表:
* @注意事项:
***************************************************************************/
public float getFloatFields(int nIndex) throws SQLException
{
String strRet = set_m.getString(nIndex);
float fltRet = Float.parseFloat(strRet);
return fltRet;
}
/****************************************************************************
* @函数名称: main
* @函数用途: 主测试函数
* @参数列表:
* @注意事项:
***************************************************************************/
public static void main(String[] args) throws FileNotFoundException,
IOException, SQLException
{
JDBCConPool jpool = null;
JDBCQuery jqry = null;
String strOut = "";
try
{
jpool = new JDBCConPool("D://JavaWork//VkTOOLS//smart.cnfg");
jqry = new JDBCQuery(jpool);
//jqry.ExecuteOracleFuncSet(jpool.GetConnetion(), null, null);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
jpool.Close();
}
System.out.println(strOut);
}
public static void main3(String[] args) throws FileNotFoundException,
IOException, SQLException
{
JDBCConPool jcp = null;
JDBCQuery jqry = null;
String strOut = "";
try
{
jcp = new JDBCConPool("D://JavaWork//VkTOOLS//smart.cnfg");
jqry = new JDBCQuery(jcp);
ArrayList listPara = new ArrayList();
listPara.add("13136129752");
listPara.add("1015002");
strOut = jqry.ExecuteFunc("MassSendSms.GetCommendSongList", listPara);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
jcp.Close();
}
System.out.println(strOut);
}
/****************************************************************************
* @函数名称:
* @函数用途:
* @参数列表:
* @注意事项:
***************************************************************************/
public static void main2(String[] args)
{
JDBCConPool jcp = null;
JDBCQuery jqry = null;
try
{
jcp = new JDBCConPool("D://JavaWork//VkTOOLS//smart.cnfg");
jqry = new JDBCQuery(jcp);
ArrayList listPara = new ArrayList();
listPara.add("13136129752");
listPara.add("1015002");
listPara.add("回复或回拨 1东风破 2南风破 3西风破 4北风破 三元每首");
listPara.add("1");
//jqry.ExecuteProc("MassSendSms.SetMTScript", listPara);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
jcp.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -