/**
* 执行数据查询,结果集以数组(每一行的内容)形式存放在ArrayList中
*
* @param sqlStatement String 查询的SQL语句
* @retrurn rownum
*
*/
public int execQuery(String sqlStatement) throws SQLException {
int recounter = 0;
clearResult();
try {
ini();
rs = stmt.executeQuery(sqlStatement);
ResultSetMetaData rsmd = rs.getMetaData();
String self = null;
colLen = rsmd.getColumnCount() ;
while (rs.next()) {
String[] colValue = new String[colLen];
for (int i = 0; i < colLen; i++) {
colValue[i] = ( (self = rs.getString(i + 1 )) == null ?empty :
self.trim().length() == 0 ? empty : self.trim());
}
result.add(colValue);
recounter++;
}
return recounter;
}
catch (SQLException e) {
throw e;
}
finally {
closeConn();
}
} /**
* 执行数据查询,结果集以HashMap(每一行的内容)形式存放在ArrayList中
*
* @param sqlStatement String 查询的SQL语句
* @retrurn rownum
*/
public int execQueryName(String sqlStatement) throws SQLException {
int recounter = 0;
clearResult();
try {
ini();
rs = stmt.executeQuery(sqlStatement);
ResultSetMetaData rsmd = rs.getMetaData();
String self = null;
colLen = rsmd.getColumnCount() ;
colName = new String[colLen];
for (int i = 0; i < colLen; i++) {
colName[i] = rsmd.getColumnName(i + 1);
}
while (rs.next()) {
HashMap colValue = new HashMap();
for (int i = 0; i < colLen; i++) {
colValue.put(colName[i],
(self = rs.getString(i + 1 )) == null ? empty :
self.trim().length() == 0 ? empty : self.trim());
}
result.add(colValue);
recounter++;
}
return recounter;
}
catch (SQLException e) {
throw e;
}
finally {
closeConn();
}
}
运行select * from product left join company on product.company = company.company像这样的sql就会出现for input string""的错误!
* 执行数据查询,结果集以数组(每一行的内容)形式存放在ArrayList中
*
* @param sqlStatement String 查询的SQL语句
* @retrurn rownum
*
*/
public int execQuery(String sqlStatement) throws SQLException {
int recounter = 0;
clearResult();
try {
ini();
rs = stmt.executeQuery(sqlStatement);
ResultSetMetaData rsmd = rs.getMetaData();
String self = null;
colLen = rsmd.getColumnCount() ;
while (rs.next()) {
String[] colValue = new String[colLen];
for (int i = 0; i < colLen; i++) {
colValue[i] = ( (self = rs.getString(i + 1 )) == null ?empty :
self.trim().length() == 0 ? empty : self.trim());
}
result.add(colValue);
recounter++;
}
return recounter;
}
catch (SQLException e) {
throw e;
}
finally {
closeConn();
}
} /**
* 执行数据查询,结果集以HashMap(每一行的内容)形式存放在ArrayList中
*
* @param sqlStatement String 查询的SQL语句
* @retrurn rownum
*/
public int execQueryName(String sqlStatement) throws SQLException {
int recounter = 0;
clearResult();
try {
ini();
rs = stmt.executeQuery(sqlStatement);
ResultSetMetaData rsmd = rs.getMetaData();
String self = null;
colLen = rsmd.getColumnCount() ;
colName = new String[colLen];
for (int i = 0; i < colLen; i++) {
colName[i] = rsmd.getColumnName(i + 1);
}
while (rs.next()) {
HashMap colValue = new HashMap();
for (int i = 0; i < colLen; i++) {
colValue.put(colName[i],
(self = rs.getString(i + 1 )) == null ? empty :
self.trim().length() == 0 ? empty : self.trim());
}
result.add(colValue);
recounter++;
}
return recounter;
}
catch (SQLException e) {
throw e;
}
finally {
closeConn();
}
}
运行select * from product left join company on product.company = company.company像这样的sql就会出现for input string""的错误!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货