All pastes #388389 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-10 01:08 UTC
rendered paste body
	private SQLResult internalQuery(String sql) throws SQLException
	{
		// Create a statement
		Statement stmt = this.dbConnection.createStatement();
		// Execute the query
		
		stmt.execute(sql);
		
		ResultSet rs = stmt.getResultSet();
		
		if (sql.matches("^INSERT.*$") || sql.matches("^REPLACE.*$"))
		{			
			stmt.execute("SELECT LAST_INSERT_ID() as lastID");
			
			ResultSet lastIDR = stmt.getResultSet();
			int lastID = lastIDR.getInt(0);
			
			System.out.println("LastID = "+lastID);
			
			return new SQLResult(rs, lastID);
		}
		else
		{
			return new SQLResult(rs);
		}
	}