Skip to content

Commit

Permalink
Fixed UniDataConnection to use UniJava to create new sessions.
Browse files Browse the repository at this point in the history
git-svn-id: http://judaw.googlecode.com/svn/trunk@9 bd0e8a68-a237-11de-a69d-91aafc7ba57a
  • Loading branch information
codemaster007 committed Sep 24, 2009
1 parent 5b76306 commit 27cc083
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions edu/fresno/uniobjects/UniDataConnection.java
Expand Up @@ -14,6 +14,7 @@
import asjava.uniclientlibs.UniConnectionException;
import asjava.uniobjects.UniCommand;
import asjava.uniobjects.UniCommandException;
import asjava.uniobjects.UniJava;
import asjava.uniobjects.UniSession;
import asjava.uniobjects.UniSessionException;

Expand All @@ -36,12 +37,16 @@ public class UniDataConnection
* Constant for the UniData database type
*/
public static final String DBTYPE_UNIDATA = "UNIDATA";
/**
* The UniJava object is used to create and destroy sessions.
*/
public static UniJava UniJava = new UniJava();

protected String host;
protected String account;
protected String username;
protected String password;
protected UniSession session = new UniSession();
protected UniSession session;

/**
* Creates the connection object, passing in the connection parameters.
Expand All @@ -60,13 +65,14 @@ public UniDataConnection(String username, String password, String host, String a
}

/**
* Attempts to connect to the UniData data source.
* Uses <code>UniJava.openSession()</code> to create a new session and
* attempts to connect to the UniData data source.
* @throws UniConnectionException If there is an issue with the connection
* @throws UniSessionException If there is an issue with the session
*/
public void connect() throws UniConnectionException, UniSessionException
{
this.session = new UniSession();
this.session = UniDataConnection.UniJava.openSession();
this.session.setUserName(this.getUsername());
this.session.setPassword(this.getPassword());
this.session.setHostName(this.getHost());
Expand All @@ -77,20 +83,14 @@ public void connect() throws UniConnectionException, UniSessionException
}

/**
* Disconnects from the UniData data source.
* Disconnects from the UniData data source using
* <code>UniJava.closeSession()</code>.
* @throws UniSessionException If there is an issue with the session
* @throws NullPointerException If the session is null
*/
public void disconnect() throws UniSessionException
{
if(this.session != null)
{
this.session.disconnect();
}
else
{
throw new NullPointerException();
}
UniDataConnection.UniJava.closeSession(this.session);
}

/**
Expand Down Expand Up @@ -195,7 +195,10 @@ public List<FieldSet> getFields(FieldDefinition fieldDefinition) throws NotConne
{
String query = fieldDefinition.getQueryString();
String result = this.query(query);
return parseIntoFieldset(result, fieldDefinition);
if(result.isEmpty())
return null;
else
return parseIntoFieldset(result, fieldDefinition);
}

/**
Expand Down Expand Up @@ -231,8 +234,6 @@ protected List<FieldSet> parseIntoFieldset(String data, FieldDefinition fieldDef
while(fieldIter.hasNext())
{
String fieldData = fieldIter.next().trim();
if(fieldData.isEmpty())
continue;
if(i >= fieldDefinition.getFields().size())
continue;
Field fieldDef = fieldDefinition.getFields().get(i);
Expand Down

0 comments on commit 27cc083

Please sign in to comment.