创设触发器,报索引中丢失IN或OUT参数:1_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 创设触发器,报索引中丢失IN或OUT参数:1

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

 2013/7/12 12:17:01  高成锋  程序员俱乐部  我要评论(0)
  • 摘要:创设触发器,报索引中丢失IN或OUT参数:1调用代码如下:booleanexecutestate=false;Connectionconn=getConnection();PreparedStatementpstmt=getPrepareStatement(conn,sql);try{intresult=pstmt.executeUpdate();closeConnection(null,pstmt,conn);if(result>=0){executestate=true;}
  • 标签:索引 触发器
class="java">创设触发器,报索引中丢失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;
}

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

?

发表评论
用户名: 匿名