JDBC删除表行

JDBC:删除
public boolean delByLoginName(String loginName) {
		boolean rt = false;
		Connection conn = null;
		PreparedStatement stmt = null;
		conn = DBManager.getConnection();
		String sqlStr = "DELETE FROM RNRDSYS.DBO.T_USER_INFO "+" WHERE LOGIN_NAME = ? ";
		try {
			stmt = conn.prepareStatement(sqlStr,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			stmt.setString(1, loginName);
			stmt.executeUpdate();
			rt = true;
		}catch (Exception e) {
			e.printStackTrace();
			rt =false;
		} finally {
			try {
				if (conn != null)
					conn.close();
			} catch (Exception e) {
				logger.error("数据库无法关闭");
			}
		}
		return rt;
	}

你可能感兴趣的:(jdbc)