public synchronized XADataSource getDataSource (String dbName, boolean create) throws SQLException
{
try
{
SequeLinkDataSource xads = new SequeLinkDataSource();
int index1 = dbName.indexOf(sequelink_5_1.driverName);
if (index1 == -1)
throw new SQLException("sequelink_5_1.getDataSource - "+jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.drivers.invaliddb")+" Merant");
else
{
/*
* Strip off any spurious parameters.
*/
int index2 = dbName.indexOf(sequelink_5_1.semicolon);
String theUrl = null;
if (index2 == -1)
{
theUrl = dbName.substring(index1+sequelink_5_1.driverName.length());
}
else
{
theUrl = dbName.substring(index1+sequelink_5_1.driverName.length(), index2);
}
/*
* From the string, get the database name, the server name,
* the port, etc.
*/
int thePort = 0;
String theServer = null;
String theDbName = null;
index1 = dbName.indexOf(sequelink_5_1.databaseName);
if (index1 != -1)
{
index2 = dbName.indexOf(sequelink_5_1.semicolon, index1);
if (index2 == -1)
{
theDbName = dbName.substring(index1+sequelink_5_1.databaseName.length());
}
else
{
theDbName = dbName.substring(index1+sequelink_5_1.databaseName.length(), index2);
}
}
if (theDbName != null)
xads.setDatabaseName(theDbName);
index1 = theUrl.indexOf(sequelink_5_1.colon);
if (index1 != -1)
{
try
{
Integer i = new Integer(theUrl.substring(index1+1));
thePort = i.intValue();
}
catch (Exception e)
{
throw new SQLException(e.toString());
}
theServer = theUrl.substring(0, index1);
}
else
{
theServer = theUrl;
}
xads.setServerName(theServer);
xads.setPortNumber(thePort);
return xads;
}
}
catch (SQLException e1)