void JDBCTemplate::executeUpdate(std::string sql, int type, object *obj) { Connection *conn = 0; try { //调用钩子方法 conn = this->getConnection(); PreparedStatement *pstmt = conn->prepareStatement(sql); //调用原语操作 this->setUpdateSqlValue(type,pstmt,obj); pstmt->executeUpdate(); pstmt->close(); } catch(Exception *err) { err->printStackTrace(); } //JAVA TO C++ CONVERTER TODO TASK: There is no native C++ equivalent to the exception 'finally' clause: finally { try { conn->close(); } catch (SQLException *e) { e->printStackTrace(); } } }
int nuodb_statement_close(struct nuodb *db, struct nuodb_statement **st) { try { if (st && *st) { PreparedStatement *stmt = reinterpret_cast<PreparedStatement *>(*st); stmt->close(); *st = 0; } return 0; } catch (SQLException &e) { return setError(db, e); } }
int nuodb_statement_prepare(struct nuodb *db, const char *sql, struct nuodb_statement **st, int *parameter_count) { PreparedStatement *stmt = 0; try { stmt = db->conn->prepareStatement(sql, RETURN_GENERATED_KEYS); *parameter_count = stmt->getParameterMetaData()->getParameterCount(); *st = reinterpret_cast<struct nuodb_statement *>(stmt); return 0; } catch (SQLException &e) { if (stmt) { stmt->close(); } return setError(db, e); } }
Collection *JDBCTemplate::getByCondition(std::string sql, object *qm) { Collection *col = std::vector(); Connection *conn = 0; try { //调用钩子方法 conn = this->getConnection(); //调用原语操作 sql = this->prepareQuerySql(sql, qm); PreparedStatement *pstmt = conn->prepareStatement(sql); //调用原语操作 this->setQuerySqlValue(pstmt, qm); ResultSet *rs = pstmt->executeQuery(); while(rs->next()) { //调用原语操作 col->add(this->rs2Object(rs)); } rs->close(); pstmt->close(); } catch(Exception *err) { err->printStackTrace(); } //JAVA TO C++ CONVERTER TODO TASK: There is no native C++ equivalent to the exception 'finally' clause: finally { try { conn->close(); } catch (SQLException *e) { e->printStackTrace(); } } return col; }