protected boolean alreadyin(String tname,String colname, String value) { int result; ResultSet rst=null; try { //执行SQL语句 String query = "select "+colname+" from "+tname+" where "+colname+"='"+value+"'"; Statement statement = connformax.createStatement(); rst = statement.executeQuery( query ); if(rst.next()) { statement.close(); rst.close(); return true; } } catch ( SQLException sqlex ) { sqlex.printStackTrace(); return false; } return false; } |