# ResultSet Serialisieren



## SwingTänzer (22. April 2004)

Hallöchen,

ich habe eine Client/Server Stream verbindung per ObjectStreams. Ich möchte gerne ein Objekt übergeben das ein ResultSet enthält. Das Objekt ist bereits ala 

```
public class Message implements Serializable
```
  serialisiert.

Nun bekomme ich aber:  

```
writing aborted; java.io.NotSerializableException: com.mysql.jdbc.ResultSet
```

Kann mir vielleicht jemand erklären wie man ein ResultSet Serialisiert?

Gruß SwingTänzer


----------



## Thomas Darimont (22. April 2004)

Hallo!

Entweder ...
http://forum.java.sun.com/thread.jsp?forum=58&thread=420032

... oder du schaust dir (wenn vorhanden) die Passende RowSet Implementierung des Datenbanksystems deiner Wahl an ...

Gruß Tom


----------



## SwingTänzer (23. April 2004)

Jo danke, werd mir das mal angucken.

Mal sehen ob ich damit klar komme  

Gruß Swingi


----------



## SwingTänzer (23. April 2004)

Hat geklappt. Klasse!
Gruß SwingTänzer


----------



## Christian Fein (23. April 2004)

Poste den funktionierenden Code doch mal hier dazu, 
dann haben jene die später sowas auch was davon


----------



## SwingTänzer (26. April 2004)

*Code posten*

Da hier ja nach "funktionierenden" Code verlangt wurde, bitteschön, komme der Aufforderung nach. Hoffe ihr könnt was damit anfangen..

```
// Datei: ServerThread.java

package net_server;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import javax.net.ssl.SSLSocket;

public class SSLServerThread extends Thread {
	/**
	 * Socket vom gebundenen Client
	 */
	private SSLSocket clientSocket;
	/**
	 * Interpretiert die vom Client empfangene Message. Führt dann alle nötigen
	 * Verarbeitungen durch und gibt dann eine Rückgabe, wieder vom Typ Message
	 */
	private InterpretMessage execMessage;
	/**
	 * Die vom Client empfangene Message
	 */
	private Message msgFromClient;
	/**
	 * Enthält das Ergebnis, des vom Client empfangenen Kommando
	 */
	private Message msgResult;
	/**
	 * liest aus dem Socket (ObjectInputStream)
	 */
	private ObjectInputStream readSocket = null;
	/**
	 * schreibt in den Socket (ObjectOutputStream)
	 */
	private ObjectOutputStream writeSocket = null;
	/**
	 * Identifikationsnummer des SSLServerThread, als auch für den Client
	 */
	private int id;
	/**
	 * Gibt an ob der SSLServerThread weiterlaufen soll
	 */
	private boolean running;

	/**
	 * Konstruktur erstellt einen SSLServerThread
	 * @param clientSocket Socket vom gebundenen Client
	 * @param id vom Server vergebene 
	 */
	public SSLServerThread(SSLSocket clientSocket, int id) {
		this.clientSocket = clientSocket;
		this.id = id;
		this.execMessage = new InterpretMessage(this);
		running = true;
		this.start();
	}

	/**
	 * Liest Message vom Client, lässt diese auswerten und schickt das 
	 * die ResultMessage zurück zum Client.
	 */
	public void run() {
		
		try {
			System.out.println("Mit Client " + getId() + " verbunden...");
			readSocket =
				new ObjectInputStream(this.clientSocket.getInputStream());

			while ((msgFromClient = (Message) readSocket.readObject()) != null) {
				// Warum muss ich den jedesmal neu erstellen?
				writeSocket =
					new ObjectOutputStream(clientSocket.getOutputStream());

				// Auswerten der Message
				msgResult = execMessage.executeCommand(msgFromClient);

				// Rückgabe des Ergebnisses an den Client
				writeSocket.writeObject(msgResult);

				if (!isRunning()) {
					break;
				}
				// Trennen der Messageausgaben
				System.out.println("----------------------------------");
			}

		}
		catch (ClassNotFoundException e) {
			System.out.println("Probleme beim Casten der Message");
			e.printStackTrace();
		}
		catch (IOException e) {
			System.out.println("Verbindung lies sich nicht erstellen...");
			System.out.println(e.getMessage());
		}
	}

	/**
	 * Soll die geöffneten Verbindungen schliessen. In diesem Fall, den 
	 * writeSocket, readSocket und den clientSocket
	 * @param Message vom Typ Message.ISTEXT, enthält das Commando "quit" und
	 * wird zum Client zurück geschrieben, damit auch dort alle Verbindungen 
	 * fehlerfrei  beendet werden können.
	 * @throws IOException können von den drei Sockets bei Auftretenden Fehlern beim schliessen ausgelöst werden.
	 */
	protected void closeAll(Message msg) throws IOException {
		int failures = 0;
		writeSocket.writeObject(msg);
		if (writeSocket != null) {
			try {
				writeSocket.close();
			}
			catch (IOException e) {
				failures++;
				e.printStackTrace();
			}
		}
		if (readSocket != null) {
			try {
				readSocket.close();
			}
			catch (IOException e) {
				failures++;
				e.printStackTrace();
			}
		}
		if (clientSocket != null) {
			try {
				clientSocket.close();
			}
			catch (IOException e1) {
				failures++;
				e1.printStackTrace();
			}
		}
		if (failures > 0) {
			throw new IOException();
		}
		else {
			System.out.println("Es wurden alle Sockets geschlossen!");
		}
	}

	/**
	 * Setzt die Variable running = false. Hiermit wird der Thread gestoppt.
	 */
	protected synchronized void stopRunning() {
		running = false;
	}

	/**
	 * @return gibt die Variable running zurück. Diese gibt mit true an, ob der SSLServerThread noch weiter laufen soll.
	 */
	private synchronized boolean isRunning() {
		return running;
	}

	/**
	 * @return ID des verbundenen Clients
	 */
	public int getId() {
		return id;
	}

}
```

Interpretiert wird die emfangene Message hier:

```
/* Filename: InterpretMessage.java
 * 
 * Created on 25.04.2004
 **/
package net_server;

import java.io.IOException;
import java.sql.SQLException;

import db.DBDemo;

public class InterpretMessage {
	private SSLServerThread server;

	/**
	 * Konstruktor von InterpretMessage
	 * @param server SSLServerThread der eine Instanz von InterpretMessage
	 * aufgerufen hat
	 */
	public InterpretMessage(SSLServerThread server) {
		this.server = server;
	}

	/**
	 * Interpretiert die Empfangene Message und bearbeitet diese.
	 * @param msg vom Typ Text oder SQL-Query
	 * @return Message, die das jeweilige Ergebnis, bezüglich der erhaltenen
	 * Message enthält
	 */
	protected Message executeCommand(Message msg) {
		Message resultMsg;

		System.out.println("Client " + server.getId() + " :");
		switch (msg.getType()) {

			case MessageTypes.IS_SQL_QUERY :
				System.out.println("Message ist vom Typ SQL_Query...");
				if (msg.getSqlQuery() == "") {
					resultMsg =
						new Message(
							"SQL- Query war leer!",
							MessageTypes.IS_TEXT);
				}
				else {
					resultMsg = callDatabase(msg);
					System.out.println(msg.getSqlQuery());
					System.out.println(resultMsg.getResult());
				}
				break;

			case MessageTypes.IS_TEXT :
				System.out.println("Message ist vom Typ Text...");

				if (msg.getText().equalsIgnoreCase("quit")) {
					System.out.println(
						"Client " + server.getId() + " möchte beenden : quit");
					try {
						server.closeAll(msg);
						System.out.println(
							"Client "
								+ server.getId()
								+ " wurde fehlerfrei beendet!");
						server.stopRunning();
						// ist egal, muss aber wegen Rückgabewert
						return msg;
					}
					catch (IOException e1) {
						System.out.println(
							"Ein oder mehrere Sockets/Streams, konnten nicht geschlossen werden...");
						e1.printStackTrace();
					}
				}
				System.out.println(
					"Gelesen vom Client "
						+ server.getId()
						+ " : "
						+ msg.getText());

				resultMsg = new Message(msg.getText(), MessageTypes.IS_TEXT);
				break;

			default :
				System.out.println("Message ist vom Typ: Unbekannt!");
				resultMsg =
					new Message(
						"Fehler: Kommando ist nicht bekannt...",
						MessageTypes.IS_TEXT);
				break;

		}
		return resultMsg;
	}

	/**
	 * Stellt die Verbindung zur Datenbank her
	 * @param msg SQL-Query
	 * @return Message, die entweder ein ResultSet oder eine Fehlermessage
	 * enthält
	 */
	private Message callDatabase(Message msg) {
		Message result;

		DBDemo db = new DBDemo();
		try {
			SerializedResultSet check = db.query(msg.getSqlQuery());
			if (check == null) {
				result =
					new Message(
						"Das ResultSet enthaelt keine Eintraege...",
						MessageTypes.IS_TEXT);
			}
			else {
				result = new Message(check);
			}

		}
		catch (SQLException e) {
			result = new Message(e.getMessage(), MessageTypes.IS_TEXT);
		}
		return result;
	}
}
```

hier die Klasse mit der ich BEISPIELHAFT! auf die Datenbank zugreife


```
package db;

import java.sql.DriverManager;
import java.sql.SQLException;

import net_server.SerializedResultSet;

/* Filename: DBDemo.java
 * 
 * Created on 07.04.2004
 **/

public class DBDemo {

	private String treiber = "org.gjt.mm.mysql.Driver";
	private String url = URL deiner Datenbank 
	
	private java.sql.Connection con;

	public DBDemo() {
		try {
			Class.forName(treiber);
			con = DriverManager.getConnection(url);
		}
		catch (Exception e) {
			System.out.println(
				"Es konnte keine Verbindung aufgebaut werden...");
			System.out.println(e);
			System.exit(1);
		}

		/*		try {
					con.close();
				}
				catch (SQLException e) {
					
					System.out.println("Verbindung lies sich nicht schliessen...");
					System.exit(0);
				}
		*/

	}

	public SerializedResultSet query(String query) throws SQLException {
		java.sql.Statement tmpStatement = null;
		java.sql.ResultSet resultSet = null;
		try {
			tmpStatement =
				con.createStatement(
					java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,
					java.sql.ResultSet.CONCUR_UPDATABLE);
			resultSet = tmpStatement.executeQuery(query);
			java.sql.ResultSetMetaData columnNames = resultSet.getMetaData();
			SerializedResultSet sResultSet = new SerializedResultSet();
			for (int i = 1; i <= columnNames.getColumnCount(); i++) {
				sResultSet.addColumn(columnNames.getColumnName(i), i);
			}
			while (resultSet.next()) {
				for (int column = 1;
					column <= columnNames.getColumnCount();
					column++) {
					sResultSet.addColumnData(
						column,
						resultSet.getObject(column));
				}
			}
			resultSet.close();
			tmpStatement.close();
			tmpStatement = null;
			resultSet = null;
			if (sResultSet.recordCount() > 0) {
				return sResultSet;
			}
			else {
				//no record found
				return null;
			}

		}
		catch (java.sql.SQLException ex) {
			throw new SQLException();
		}
	}

	public void closeConnection() throws Exception {
		try {
			con.close();
		}
		catch (SQLException e) {
			Exception SQLException = null;
			e.printStackTrace();
			throw SQLException;
		}
	}

	public void test() throws SQLException {
		String sql = "select * FROM File";

		java.sql.Statement stmt = con.createStatement();
		java.sql.ResultSet result = stmt.executeQuery(sql);
		System.out.println("Gelesen aus der DB: ");
		while (result.next()) {
			System.out.println(
				"\nUID = "
					+ result.getInt("LfdNr")
					+ "\nUser = "
					+ result.getString("Filename")
					+ "\nPassword = "
					+ result.getString("Path"));
		}
	}
}
```


----------



## SwingTänzer (26. April 2004)

*Teil 2*

Dann erstmal noch das Objekt indem sich das ResultSet befindet:

```
/* Filename: Message.java
*/
package net_server;

import java.io.Serializable;

public class Message implements Serializable {

	private String text;
	private String sqlQuery;
	private SerializedResultSet result;
	private int type;

	/**
	 * Konstruktor um eine Text- Message zu erstellen
	 * @param text Textnachricht die übertragen werden soll
	 */
	public Message(String text, int type) {
		switch (type) {
			case MessageTypes.IS_SQL_QUERY :
				this.sqlQuery = text;
				break;

			default :
				this.sqlQuery = text;
				break;
		}

		this.type = type;
	}
	/**
	 * Konstruktor um eine ResultSet- Message zu erstellen
	 * @param result ResultSet das übertragen werdens soll
	 */
	public Message(SerializedResultSet result) {
		this.result = result;
		this.type = MessageTypes.IS_RESULSET;
	}
	/**
	 * Kann den Typ der Message aendern, damit bei Problemen reagiert werden kann
	 * @param type Typ der Message
	 */
	public void setType(int type) {
		this.type = type;
	}
	/**
	 * @return gespeichertes ResultSet
	 */
	public SerializedResultSet getResult() {
		return result;
	}
	/**
	 * @return gespeicherten Text- Message
	 */
	public String getText() {
		return text;
	}
	/**
	 * @return Typ der Message
	 */
	public int getType() {
		return type;
	}
	/**
	 * @return SQL- Anfrage als String
	 */
	public String getSqlQuery() {
		return sqlQuery;
	}
}
```
Das ResultSet benutzt noch die Klasse XList, diese und das SerializedResultSet habe ich aus dem java.sun.com Forum

```
/* Filename: XList.java
 * 
  * 
 * Created on 23.04.2004
 **/
package net_server;

/**This class may be used in place of Hashtable.*/
public class XList
	extends java.util.Hashtable
	implements java.io.Serializable {

	public XList() {
	}

	/**
	* Get the total numbers of objects in the list.
	*
	* @return <code>int</code> the total items in the list.
	* */
	public int countItem() {
		return super.size();
	}

	/**
	* An Iterator Object which may be used to iterate the list.
	*
	* @return java.util.Iterator Object
	* */
	public java.util.Iterator getIterator() {
		return this.values().iterator();
	}

	/**
	* This method add a new value with key in the list.
	*
	* @param key The key where the object is to be placed.
	* @param value The value to be stored.
	* @return <code>true</code> if the value is successfully inserted in the list;<code>false</code> otherwise.
	* */
	public boolean addItem(Object key, Object value) {
		// if key already exist in the list
		if (super.containsKey(key)) {
			System.out.println("Key already exist..");
			return false;
		}
		else { // end of IF condition
			try {
				super.put(key, value);
				return true;
			}
			catch (Exception ex) {
				System.out.println(ex.toString());
				return false;
			}
		}
	}

	/**
	* This method replace an existing value with a new value in the list.
	*
	* @param oldkey The key of the object to be replaced.
	* @param newvalue The new value of the Object.
	* @return <code>true</code> if the value is successfully replaced in the list;<code>false</code> otherwise.
	* */
	public boolean replaceItem(Object oldkey, Object newvalue) {
		if (!(super.containsKey(oldkey))) {
			System.out.println("Key does not exist..");
			return false;
		}
		else {
			try {
				super.put(oldkey, newvalue);
				return true;
			}
			catch (Exception ex) {
				System.out.println(ex.toString());
				return false;
			}
		}
	}

	/**
	* This method returns a value from the list.
	*
	* @param key The key of the value to be searched.
	* @return <code>Object</code>
	* */
	public Object searchItem(Object key) {
		try {
			return super.get(key);
		}
		catch (Exception ex) {
			System.out.println(ex.toString());
			return null;
		}
	}

	/**
	* Delete a value from the list.
	*
	* @param key The key of the value to be deleted.
	* @return <code>true</code> if the item is deleted successfully; <code>false</code> otherwise.
	* */
	public boolean deleteItem(Object key) {
		if (!(super.containsKey(key))) {
			System.out.println("Error Occured: Key does not exist");
			return false;
		}
		else {
			try {
				super.remove(key);
				return true;
			}
			catch (Exception ex) {
				System.out.println(ex.toString());
				return false;
			}
		}
	}

	/**
	* Test that if list is empty.
	*
	* @return <code>true</code> if the list is empty; <code>false</code> otherwise.
	* */
	public boolean isEmpty() {
		return super.isEmpty();
	}

	/**
	* Removes all the vlaue from the list.
	*
	* @return <code>true</code> if the list is emptied successfully; <code>false</code> otherwise.
	* */
	public boolean clearList() {
		try {
			super.clear();
			return true;
		}
		catch (Exception ex) {
			System.out.print(ex.toString());
			return false;
		}
	}

} //End of Class
```

schliesslich das eigentliche ResultSet

```
/* Filename: SerializedResultSet.java
 * 
 * Created on 23.04.2004
 **/
package net_server;

import java.io.IOException;


/**A duplicate of java.sql.ResultSet which can be used in place of java.sql.ResultSet when using RMI.*/
public class SerializedResultSet implements java.io.Serializable {

	private XList lstColumnName = new XList();
	private java.util.LinkedList lstColumnData = new java.util.LinkedList();
	private int currentRecord = -1;
	private int totalRecords = 0;

	public SerializedResultSet() {
		currentRecord = -1;
		totalRecords = 0;
	}

	/**
	* Moves the cursor down one row from its current position in the result set.
	* Initially the cursor is at the top of the first row.
	*
	* @return <code>true</code> if the new current row is valid;
	* <code>false</code> otherwise.
	* @throws Exception
	* */
	public boolean next() throws IOException {
		int totalRecords = recordCount();
		if (totalRecords == 0) {
			currentRecord = 0;
			return false;
		}
		if (currentRecord == -1) {
			currentRecord = 0;
			return true;
		}
		if (currentRecord < totalRecords
			&& currentRecord >= 0
			&& currentRecord != (totalRecords - 1)) {
			currentRecord++;
			return true;
		}
		return false;
	}

	/**
	* Returns the total number of records in the resultset.
	*
	* @return <code>integer</code> the total number of records in the result set.
	* */
	public int recordCount() {
		try {
			java.util.LinkedList columnData =
				(java.util.LinkedList) lstColumnData.get(0);
			return columnData.size();
		}
		catch (Exception ex) {
			return 0;
		}
	}

	/**
	* Positions the cursor at the first value of the result set.
	*
	* @return <code>true</code> if the first row is valid;
	* <code>false</code> otherwise.
	* @throws Exception
	* */
	public boolean first() throws Exception {
		currentRecord = -1;
		return true;
	}

	/**
	* Positions the cursor at the last value of the table result set.
	*
	* @return <code>true</code> if the first row is valid;
	* <code>false</code> otherwise.
	* @throws Exception
	* */
	public boolean last() throws Exception {
		currentRecord = recordCount() - 1;
		return true;
	}

	/**
	* Get the field value specifed by the column name and the row.
	*
	* @param columnName The name of the table column.
	* @param row The row number int the column.
	* @return An <code>Object</code> containing the data.
	* @throws Exception if the row number is greater than the size of the
	* column data or given the column name is invalid.
	* */
	private Object getField(String columnName, int row) throws Exception {
		if (row == -1) {
			currentRecord++;
			row = currentRecord;
		}
		int iColumnIndex =
			Integer
				.valueOf(
					(String) lstColumnName.searchItem(
						columnName.toUpperCase()))
				.intValue();
		java.util.LinkedList columnData =
			((java.util.LinkedList) lstColumnData.get(iColumnIndex - 1));
		return columnData.get(row);
	}

	/**
	* Get a String value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>String</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public String getString(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return null;
		}
		else {
			return obj.toString();
		}
	}

	/**
	* Get Date and Time specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>String</code> containing the date and time.
	* @throws Exception if an invalid column Name is given.
	* */
	public String getDateTime(String columnName) throws Exception {
		java.sql.Timestamp dateTime =
			(java.sql.Timestamp) this.getField(columnName, currentRecord);
		if (dateTime != null) {
			java.text.SimpleDateFormat dateFormat =
				new java.text.SimpleDateFormat("MMM-dd-yyyy HH:mm:ss");
			return dateFormat.format(new java.util.Date(dateTime.getTime()));
		}
		else {
			return null;
		}
	}

	/**
	* Get Date specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>String</code> containing the date.
	* @throws Exception if an invalid column Name is given.
	* */
	public String getDate(String columnName) throws Exception {
		java.sql.Timestamp dateTime =
			(java.sql.Timestamp) this.getField(columnName, currentRecord);
		if (dateTime != null) {
			java.text.SimpleDateFormat dateFormat =
				new java.text.SimpleDateFormat("MMM-dd-yyyy");
			return dateFormat.format(new java.util.Date(dateTime.getTime()));
		}
		else {
			return null;
		}
	}

	/**
	* Get Time specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>String</code> containing the time.
	* @throws Exception if an invalid column Name is given.
	* */
	public String getTime(String columnName) throws Exception {
		java.sql.Timestamp dateTime =
			(java.sql.Timestamp) this.getField(columnName, currentRecord);
		if (dateTime != null) {
			java.text.SimpleDateFormat dateFormat =
				new java.text.SimpleDateFormat("HH:mm:ss");
			return dateFormat.format(new java.util.Date(dateTime.getTime()));
		}
		else {
			return null;
		}
	}

	/**
	* Get an Object specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return An <code>Object</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public Object getObject(String columnName) throws Exception {
		return this.getField(columnName, currentRecord);
	}

	/**
	* Get an integer value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return An <code>integer</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public int getInteger(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return 0;
		}
		else {
			return ((java.math.BigDecimal) obj).intValue();
		}
	}

	/**
	* Get a long value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>long</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public long getLong(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return 0;
		}
		else {
			try {
				return ((java.math.BigDecimal) obj).longValue();
			}
			catch (Exception ex) {
				try {
					return ((Long) obj).longValue();
				}
				catch (Exception ex1) {
					return ((Integer) obj).longValue();
				}
			}
		}

	}

	/**
	* Get a double value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>double</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public double getDouble(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return 0;
		}
		else {
			try {
				return ((java.math.BigDecimal) obj).doubleValue();
			}
			catch (Exception ex) {
				try {
					double ret = ((Double) obj).doubleValue();
					return ret;
				}
				catch (Exception e) {
					return 0.0;
				}
			}
		}

	}

	/**
	* Get a java.sql.Timestamp Object specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return An <code>java.sql.Timestamp Object</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public java.sql.Timestamp getTimestamp(String columnName)
		throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return null;
		}
		else {
			return ((java.sql.Timestamp) obj);
		}

	}

	/**
	* Get a double value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return A <code>double</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public double getDecimal(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return 0;
		}
		else {
			return ((Double) obj).doubleValue();
		}
	}

	/**
	* Get a integer value specified by the column name.
	*
	* @param columnName The name of the table column.
	* @return An <code>integer</code> containing the data.
	* @throws Exception if an invalid column Name is given.
	* */
	public int getInt(String columnName) throws Exception {
		Object obj = this.getField(columnName, currentRecord);
		if (obj == null) {
			return 0;
		}
		else {
			try {
				return ((Integer) obj).intValue();
			}
			catch (Exception ex) {
				try {
					return ((java.math.BigDecimal) obj).intValue();
				}
				catch (Exception ex1) {
					return ((Long) obj).intValue();
				}
			}
		}

	}

	/**
	* Adds column data to the list.
	*
	* @param ColumnNumber The index of the column.
	* @param newValue The new value to be added.
	* */
	public void addColumnData(int ColumnNumber, Object newValue) {
		((java.util.LinkedList) lstColumnData.get(ColumnNumber - 1)).addLast(
			newValue);
	}

	/**
	* Adds column name to the list.
	*
	* @param columnName The name of the column.
	* @param columnSequence The index of the column.
	* */
	public void addColumn(String columnName, int columnSequence) {
		lstColumnName.addItem(
			columnName.toUpperCase(),
			String.valueOf(columnSequence));
		java.util.LinkedList linkData = new java.util.LinkedList();
		lstColumnData.addLast(linkData);
		((java.util.LinkedList) lstColumnData.get(columnSequence - 1)).clear();
	}
}
```


----------



## SwingTänzer (26. April 2004)

Ups... hoffentlich war es nicht zuviel Text ...


So... habe nicht soviel Zeit... falls noch Fragen sind, ich kann ja mal probieren sie zu beantworten ;-)

Gruß SwingTänzer


----------



## Christian Fein (27. April 2004)

> _Original geschrieben von SwingTänzer _
> *Ups... hoffentlich war es nicht zuviel Text ...
> 
> 
> ...




hehe ich meinte eigentlich nur den betreffenden Teil der dein Problem löste 

Hätte ich dich nicht dazu aufgefordert müsste ich dich jetzt zusammenscheissen


----------

