// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) package org.jdbcpersistence.generated; import example.ExampleUserBeanImpl; import java.sql.*; import org.jdbcpersistence.JDBCPersistor; import org.jdbcpersistence.db.SQLUtils; public final class ExampleUserBeanImplJDBCPersistor implements JDBCPersistor { public ExampleUserBeanImplJDBCPersistor() { } public Object load(Connection connection, Object aobj[]) throws SQLException, RuntimeException { PreparedStatement psSelect = null; ResultSet rsSelect = null; ExampleUserBeanImpl result = null; try { psSelect = connection.prepareStatement("SELECT FIRST_NAME,LAST_NAME,AGE FROM EXAMPLE_USERS WHERE ID=?"); psSelect.setString(1, (String)aobj[0]); if((rsSelect = psSelect.executeQuery()).next()) { result = new ExampleUserBeanImpl(); result.setId((String)aobj[0]); result.setFirstName(rsSelect.getString(1)); result.setLastName(rsSelect.getString(2)); result.setAge(rsSelect.getInt(3)); } } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(rsSelect, psSelect); } return result; } public int insert(Connection connection, Object obj) throws SQLException, RuntimeException { PreparedStatement psInsert = null; int result; try { psInsert = connection.prepareStatement("INSERT INTO EXAMPLE_USERS (ID,FIRST_NAME,LAST_NAME,AGE) VALUES (?,?,?,?)"); ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)obj; psInsert.setString(1, exampleuserbeanimpl.getId()); String s; if((s = exampleuserbeanimpl.getFirstName()) != null) psInsert.setString(2, s); else psInsert.setNull(2, 12); String s1; if((s1 = exampleuserbeanimpl.getLastName()) != null) psInsert.setString(3, s1); else psInsert.setNull(3, 12); psInsert.setInt(4, exampleuserbeanimpl.getAge()); result = psInsert.executeUpdate(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, psInsert); } return result; } public int[] insert(Connection connection, Object aobj[]) throws SQLException, BatchUpdateException, RuntimeException { PreparedStatement psInsert = null; int result[]; try { psInsert = connection.prepareStatement("INSERT INTO EXAMPLE_USERS (ID,FIRST_NAME,LAST_NAME,AGE) VALUES (?,?,?,?)"); for(int objArrayIndex = 0; objArrayIndex < aobj.length; objArrayIndex++) { ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)aobj[objArrayIndex]; psInsert.setString(1, exampleuserbeanimpl.getId()); String s; if((s = exampleuserbeanimpl.getFirstName()) != null) psInsert.setString(2, s); else psInsert.setNull(2, 12); String s1; if((s1 = exampleuserbeanimpl.getLastName()) != null) psInsert.setString(3, s1); else psInsert.setNull(3, 12); psInsert.setInt(4, exampleuserbeanimpl.getAge()); psInsert.addBatch(); } result = psInsert.executeBatch(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, psInsert); } return result; } public int update(Connection connection, Object obj) throws SQLException, RuntimeException { PreparedStatement psUpdate = null; int result; try { psUpdate = connection.prepareStatement("UPDATE EXAMPLE_USERS SET FIRST_NAME=?,LAST_NAME=?,AGE=? WHERE ID=?"); ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)obj; String s; if((s = exampleuserbeanimpl.getFirstName()) != null) psUpdate.setString(1, s); else psUpdate.setNull(1, 12); String s1; if((s1 = exampleuserbeanimpl.getLastName()) != null) psUpdate.setString(2, s1); else psUpdate.setNull(2, 12); psUpdate.setInt(3, exampleuserbeanimpl.getAge()); psUpdate.setString(4, exampleuserbeanimpl.getId()); result = psUpdate.executeUpdate(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, psUpdate); } return result; } public int[] update(Connection connection, Object aobj[]) throws SQLException, BatchUpdateException, RuntimeException { PreparedStatement psUpdate = null; int result[]; try { psUpdate = connection.prepareStatement("UPDATE EXAMPLE_USERS SET FIRST_NAME=?,LAST_NAME=?,AGE=? WHERE ID=?"); for(int objArrayIndex = 0; objArrayIndex < aobj.length; objArrayIndex++) { ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)aobj[objArrayIndex]; String s; if((s = exampleuserbeanimpl.getFirstName()) != null) psUpdate.setString(1, s); else psUpdate.setNull(1, 12); String s1; if((s1 = exampleuserbeanimpl.getLastName()) != null) psUpdate.setString(2, s1); else psUpdate.setNull(2, 12); psUpdate.setInt(3, exampleuserbeanimpl.getAge()); psUpdate.setString(4, exampleuserbeanimpl.getId()); psUpdate.addBatch(); } result = psUpdate.executeBatch(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, psUpdate); } return result; } public int delete(Connection connection, Object obj) throws SQLException, RuntimeException { PreparedStatement preparedstatement = null; int result; try { preparedstatement = connection.prepareStatement("DELETE FROM EXAMPLE_USERS WHERE ID=?"); ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)obj; preparedstatement.setString(1, exampleuserbeanimpl.getId()); result = preparedstatement.executeUpdate(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, preparedstatement); } return result; } public int[] delete(Connection connection, Object aobj[]) throws SQLException, BatchUpdateException, RuntimeException { PreparedStatement preparedstatement = null; int result[]; try { preparedstatement = connection.prepareStatement("DELETE FROM EXAMPLE_USERS WHERE ID=?"); for(int objArrayIndex = 0; objArrayIndex < aobj.length; objArrayIndex++) { ExampleUserBeanImpl exampleuserbeanimpl = (ExampleUserBeanImpl)aobj[objArrayIndex]; preparedstatement.setString(1, exampleuserbeanimpl.getId()); preparedstatement.addBatch(); } result = preparedstatement.executeBatch(); } catch(SQLException sqlexception) { throw sqlexception; } catch(Throwable throwable) { RuntimeException runtimeexception = new RuntimeException(throwable); throw runtimeexception; } finally { SQLUtils.close(null, preparedstatement); } return result; } private static byte dba_[] = new byte[1]; private static String ds_ = " "; }