日期:2014-05-16  浏览次数:20463 次

创设触发器,报索引中丢失IN或OUT参数:1
创设触发器,报索引中丢失IN或OUT参数:1


调用代码如下:

boolean executestate = false;
Connection conn = getConnection();
PreparedStatement pstmt = getPrepareStatement(conn, sql);
try {
	int result = pstmt.executeUpdate();
	closeConnection(null, pstmt, conn);
	if (result >= 0) {
		executestate = true;
	}
} catch (SQLException e) {
	e.printStackTrace();
}
return executestate;

//----------------------------------------
public static PreparedStatement getPrepareStatement(Connection conn,
			String sql) {

	PreparedStatement stmt = null;
	try {
		if (conn != null) {
			stmt = conn.prepareStatement(sql);
		}

	} catch (SQLException e) {
		e.printStackTrace();
	}
	return stmt;
}

一直找不到原因,后来将代码调整如下就可以了:


boolean executestate = false;
Connection conn = getConnection();
Statement stmt = getStatement(conn);
try {
	int result = stmt.executeUpdate(sql);
	closeConnection(null, pstmt, conn);
	if (result >= 0) {
		executestate = true;
	}
} catch (SQLException e) {
	e.printStackTrace();
}
return executestate;

//-------------------------
public static PreparedStatement getStatement(Connection conn) {

	PreparedStatement stmt = null;
	try {
		if (conn != null) {
			stmt = conn.createStatement();
		}

	} catch (SQLException e) {
		e.printStackTrace();
	}
	return stmt;
}

不知道是不是在对触发器进行预编译的时候有什么机制需要验证不,最后我也只能这样处理这个问题了

?