}
public static DatabaseFileInfo getDatabaseFileInfo(String catalogName, ISQLConnection conn)
throws java.sql.SQLException
{
DatabaseFileInfo dbInfo = new DatabaseFileInfo();
Connection c = conn.getConnection();
CallableStatement stmt = null;
ResultSet rs = null;
try
{
stmt = c.prepareCall("{ call sp_helpdb ? }");
stmt.setString(1, catalogName);
if (!stmt.execute()) return null;
rs = stmt.getResultSet();
rs.next();
dbInfo.setDatabaseName(rs.getString(1));
dbInfo.setDatabaseSize(rs.getString(2));
dbInfo.setOwner(rs.getString(3));
dbInfo.setCreatedDate(rs.getString(5));
String[] options = rs.getString(6).split(", ");
dbInfo.setCompatibilityLevel(rs.getShort(7));
// dbStatus -> `Status=ONLINE, Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=SIMPLE,
// Version=539, Collation=SQL_Latin1_General_CP1_CI_AS, SQLSortOrder=52, IsTornPageDetectionEnabled,
// IsAutoCreateStatistic'
for (int i = 0; i < options.length; i++)
{
if (options[i].indexOf('=') != -1)
{
String parts[] = options[i].split("=");
dbInfo.setOption(parts[0], parts[1]);
}
else dbInfo.setOption(options[i], "1");
}
if (!stmt.getMoreResults()) return dbInfo;
}
catch (Exception e)
{
s_log.error("getDatabaseFileInfo(1): Unexpected exception - " + e.getMessage(), e);
}
finally
{
closeResultSet(rs);
closeStatement(stmt);
}
try
{
rs = stmt.getResultSet();
while (rs.next())
{
String name = rs.getString(1).trim();
short id = rs.getShort(2);
String filename = rs.getString(3).trim();
String filegroup = rs.getString(4);
String size = rs.getString(5);
String maxSize = rs.getString(6);
String growth = rs.getString(7);
String usage = rs.getString(8);
DatabaseFile file = new DatabaseFile();
file.setName(name);
file.setId(id);
file.setFilename(filename);
file.setFilegroup(filegroup);
file.setSize(size);
file.setMaxSize(maxSize);
file.setGrowth(growth);
file.setUsage(usage);
if (filegroup == null) dbInfo.addLogFile(file);
else dbInfo.addDataFile(file);
}
}
catch (Exception e)
{
s_log.error("getDatabaseFileInfo(2): Unexpected exception - " + e.getMessage(), e);