我尝试执行以下代码时收到此错误消息.
ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议问题出在哪里?我想问题的根源是我尝试执行存储过程的部分.
存储过程在执行时创建自己的事务
using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();
SqlCommand command = conn.CreateCommand();
SqlTransaction transaction;
// Start a local transaction.
transaction = conn.BeginTransaction("createOrder");
// Must assign both transaction object and connection
// to Command object for a pending local transaction
command.Connection = conn;
command.Transaction = transaction;
try
{
command.CommandText = "INSERT INTO rand_resupply_order (study_id, centre_id, date_created, created_by) …Run Code Online (Sandbox Code Playgroud) 我有以下代码试图创建一个 jwt 令牌。每次尝试执行 SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256 时,总会出现如下所示的错误;
我已经手动删除了 jwt jar 文件并再次更新 maven 以重新安装 jar,但问题仍然存在。
任何帮助将不胜感激!
//Sample method to construct a JWT
public static String createJWT(String id, String issuer, String subject,
String payload, String role, String name, long ttlMillis) {
String jwt = "";
try {
//The JWT signature algorithm we will be using to sign the token
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
//We will sign our JWT with our ApiKey secret …Run Code Online (Sandbox Code Playgroud)