「Java」SQLExceptionの使い方
書式
throw new SQLException(xxx)
使用例
//プレースホルダーuserid String strSQL ="select * from usertbl where userid = ?"; PreparedStatement pstmt = null; ResultSet rslt = null; try { //CallableStatementオブジェクトを生成 pstmt = conn.prepareCall(strSQL) pstmt.setString(1,"202107"); //ResultSetオブジェクトを返す rslt = pstmt.executeQuery(); if(!rslt.next()) { throw new SQLException("not exist"); } } catch(Exception e){ throw new SQLException("error" + e.getMessage()); }