/**
* 根据TableName_Field生成 PreparedStatement的SQL,生成的sql语句:insert
* 2012-1-7,Xgw123485
*/
private static String getPstatementsql(TableName_Field table)
{
StringBuffer insertBuffer = new StringBuffer(50);
StringBuffer valueBuffer = new StringBuffer(20);
insertBuffer.append("insert into ").append(table.getTableName())
.append("(");
valueBuffer.append("values (");
// 生成字段名对应的SQL
for (EsbTableField esbTableField : table.getList())
{
insertBuffer.append(esbTableField.getFieldName()).append(",");
valueBuffer.append("?,");
}
// 先删除insertBuffer中的最后一个字符,加上valueBuffer去掉最后一个字符的串
return insertBuffer
.deleteCharAt(insertBuffer.length() - 1)
.append(")")
.append(valueBuffer.deleteCharAt(valueBuffer.length() - 1)
.toString()).append(")").toString();
}
/**
* seqid获取临时规避方案, 由yyyymmdd + 8位码组成,sequence需要建成可循环的 2012-1-7,Xgw123485
*/
public static String[] getSeq_id()
{
String[] seq = new String[100];
Connection connection = ConnectionTools.getConnection();
// 如果取不到数据库连接则抛出异常
if (connection == null)
{
logger.error("Can't get fetch Connection");
return null;
}
PreparedStatement pstatement = null;
ResultSet rs = null;
try
{
pstatement = connection
.prepareStatement("SELECT TO_CHAR(cle_log_seq_id.nextval,'09999999') "
+ "as seq_id FROM DUAL CONNECT BY LEVEL <=100");
rs = pstatement.executeQuery();
int index = 0;
while (rs.next())
{
seq[index++] = rs.getString("seq_id");
}
}
catch (Exception e)
{
logger.error("Get seq_id fail", e);
}
finally
{
ConnectionTools.closeResult(rs);
ConnectionTools.closeStmt(pstatement);
ConnectionTools.closeConn(connection);
}
return seq;
}
/**
* seqid获取临时规避方案, 由yyyymmdd + 14位码组成,sequence需要建成可循环的 2012-1-7,Xgw123485
*/
public static String[] getTrancking_id()
{
String[] seq = new String[100];
Connection connection = ConnectionTools.getConnection();
// 如果取不到数据库连接则抛出异常
if (connection == null)
{
logger.error("Can't get fetch Connection");
return null;
}
PreparedStatement pstatement = null;
ResultSet rs = null;
try
{
pstatement = connection
.prepareStatement("SELECT TO_CHAR(cle_log_trancking_id.nextval,'09999999999999')"
+ "as seq_id FROM DUAL CONNECT BY LEVEL<=100");
rs = pstatement.executeQuery();
int index = 0;
while (rs.next())
{
seq[index++] = rs.getString("seq_id");
}
}
catch (Exception e)
{
logger.error("Get seq_id fail", e);
}
finally
{
ConnectionTools.closeResult(rs);
ConnectionTools.closeStmt(pstatement);
ConnectionTools.closeConn(connection);
}
return seq;
}
* 根据TableName_Field生成 PreparedStatement的SQL,生成的sql语句:insert
* 2012-1-7,Xgw123485
*/
private static String getPstatementsql(TableName_Field table)
{
StringBuffer insertBuffer = new StringBuffer(50);
StringBuffer valueBuffer = new StringBuffer(20);
insertBuffer.append("insert into ").append(table.getTableName())
.append("(");
valueBuffer.append("values (");
// 生成字段名对应的SQL
for (EsbTableField esbTableField : table.getList())
{
insertBuffer.append(esbTableField.getFieldName()).append(",");
valueBuffer.append("?,");
}
// 先删除insertBuffer中的最后一个字符,加上valueBuffer去掉最后一个字符的串
return insertBuffer
.deleteCharAt(insertBuffer.length() - 1)
.append(")")
.append(valueBuffer.deleteCharAt(valueBuffer.length() - 1)
.toString()).append(")").toString();
}
/**
* seqid获取临时规避方案, 由yyyymmdd + 8位码组成,sequence需要建成可循环的 2012-1-7,Xgw123485
*/
public static String[] getSeq_id()
{
String[] seq = new String[100];
Connection connection = ConnectionTools.getConnection();
// 如果取不到数据库连接则抛出异常
if (connection == null)
{
logger.error("Can't get fetch Connection");
return null;
}
PreparedStatement pstatement = null;
ResultSet rs = null;
try
{
pstatement = connection
.prepareStatement("SELECT TO_CHAR(cle_log_seq_id.nextval,'09999999') "
+ "as seq_id FROM DUAL CONNECT BY LEVEL <=100");
rs = pstatement.executeQuery();
int index = 0;
while (rs.next())
{
seq[index++] = rs.getString("seq_id");
}
}
catch (Exception e)
{
logger.error("Get seq_id fail", e);
}
finally
{
ConnectionTools.closeResult(rs);
ConnectionTools.closeStmt(pstatement);
ConnectionTools.closeConn(connection);
}
return seq;
}
/**
* seqid获取临时规避方案, 由yyyymmdd + 14位码组成,sequence需要建成可循环的 2012-1-7,Xgw123485
*/
public static String[] getTrancking_id()
{
String[] seq = new String[100];
Connection connection = ConnectionTools.getConnection();
// 如果取不到数据库连接则抛出异常
if (connection == null)
{
logger.error("Can't get fetch Connection");
return null;
}
PreparedStatement pstatement = null;
ResultSet rs = null;
try
{
pstatement = connection
.prepareStatement("SELECT TO_CHAR(cle_log_trancking_id.nextval,'09999999999999')"
+ "as seq_id FROM DUAL CONNECT BY LEVEL<=100");
rs = pstatement.executeQuery();
int index = 0;
while (rs.next())
{
seq[index++] = rs.getString("seq_id");
}
}
catch (Exception e)
{
logger.error("Get seq_id fail", e);
}
finally
{
ConnectionTools.closeResult(rs);
ConnectionTools.closeStmt(pstatement);
ConnectionTools.closeConn(connection);
}
return seq;
}