提交 1da6dd28 编写于 作者: J jurgen

QM schema update

上级 2ca8ee79
...@@ -507,19 +507,24 @@ public class JDBCUtils { ...@@ -507,19 +507,24 @@ public class JDBCUtils {
} }
} }
public static void executeSQL(JDBCSession session, String sql) throws SQLException public static void executeSQL(Connection session, String sql, Object ... params) throws SQLException
{ {
final JDBCPreparedStatement dbStat = session.prepareStatement(sql); final PreparedStatement dbStat = session.prepareStatement(sql);
try { try {
if (params != null) {
for (int i = 0; i < params.length; i++) {
dbStat.setObject(i + 1, params[i]);
}
}
dbStat.execute(); dbStat.execute();
} finally { } finally {
dbStat.close(); dbStat.close();
} }
} }
public static void executeProcedure(JDBCSession session, String sql) throws SQLException public static void executeProcedure(Connection session, String sql) throws SQLException
{ {
final JDBCPreparedStatement dbStat = session.prepareCall(sql); final PreparedStatement dbStat = session.prepareCall(sql);
try { try {
dbStat.execute(); dbStat.execute();
} finally { } finally {
...@@ -527,6 +532,30 @@ public class JDBCUtils { ...@@ -527,6 +532,30 @@ public class JDBCUtils {
} }
} }
public static <T> T executeQuery(Connection session, String sql, Object ... params) throws SQLException
{
final PreparedStatement dbStat = session.prepareStatement(sql);
try {
if (params != null) {
for (int i = 0; i < params.length; i++) {
dbStat.setObject(i + 1, params[i]);
}
}
ResultSet resultSet = dbStat.executeQuery();
try {
if (resultSet.next()) {
return (T) resultSet.getObject(1);
} else {
return null;
}
} finally {
resultSet.close();
}
} finally {
dbStat.close();
}
}
@Nullable @Nullable
public static String queryString(JDBCSession session, String sql, Object... args) throws SQLException public static String queryString(JDBCSession session, String sql, Object... args) throws SQLException
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册