org.wso2.carbon.utils.dbcreator
Class DatabaseCreator

java.lang.Object
  extended by org.wso2.carbon.utils.dbcreator.DatabaseCreator

public class DatabaseCreator
extends Object


Constructor Summary
DatabaseCreator(DataSource dataSource)
           
 
Method Summary
static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix)
          Checks that a string buffer ends up with a given string.
 void createRegistryDatabase()
          Creates registry database
static String getDatabaseType(Connection conn)
          computes relatational database type using database name
static String getDatabaseType(String dbUrl)
          Overloaded method with String input
protected  String getDbScriptLocation(String databaseType)
           
 boolean isDatabaseStructureCreated(String checkSQL)
          Checks whether database tables are created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseCreator

public DatabaseCreator(DataSource dataSource)
Method Detail

createRegistryDatabase

public void createRegistryDatabase()
                            throws Exception
Creates registry database

Throws:
Exception

isDatabaseStructureCreated

public boolean isDatabaseStructureCreated(String checkSQL)
Checks whether database tables are created.

Parameters:
checkSQL - SQL execute during check.
Returns:
true if checkSQL is success, else false.

getDatabaseType

public static String getDatabaseType(Connection conn)
                              throws Exception
computes relatational database type using database name

Returns:
String
Throws:
Exception*
Exception

getDatabaseType

public static String getDatabaseType(String dbUrl)
                              throws Exception
Overloaded method with String input

Returns:
String
Throws:
Exception*
Exception

getDbScriptLocation

protected String getDbScriptLocation(String databaseType)

checkStringBufferEndsWith

public static boolean checkStringBufferEndsWith(StringBuffer buffer,
                                                String suffix)
Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to massive memory allocation and copying. See

Parameters:
buffer - the buffer to perform the check on
suffix - the suffix
Returns:
true if the character sequence represented by the argument is a suffix of the character sequence represented by the StringBuffer object; false otherwise. Note that the result will be true if the argument is the empty string.


Copyright © 2014 WSO2 Inc. All rights reserved.