Package com.spun.util

Class DatabaseUtils

java.lang.Object
com.spun.util.DatabaseUtils

public class DatabaseUtils
extends Object
A static class of convenience functions for database access
  • Field Details

  • Constructor Details

    • DatabaseUtils

      public DatabaseUtils()
  • Method Details

    • getDatabaseType

      public static String getDatabaseType​(int type)
    • getDatabaseType

      public static int getDatabaseType​(Statement stmt) throws SQLException
      Throws:
      SQLException
    • getDatabaseType

      public static int getDatabaseType​(Connection con) throws SQLException
      Throws:
      SQLException
    • findDatabaseName

      public static String findDatabaseName​(int i)
      Finds the database type name for a jdbc sql type
    • findSQLName

      public static String findSQLName​(int i)
      Finds the java object or primative for a sql type
    • isSqlServer

      public static boolean isSqlServer​(int databaseType)
    • makeSQL2000URL

      public static String makeSQL2000URL​(String protocol, String server, String port, String database)
    • makeMySqlURL

      public static String makeMySqlURL​(String protocol, String server, String port, String database)
      Creates a connection to the Database.
    • makeURL

      public static String makeURL​(String protocol, String server, String port, String database, int type)
      Creates a connection to the Database, and stores it in the cookies table.
    • makeJDBCAccessURL

      public static String makeJDBCAccessURL​(String protocol, String server, String port, String database)
      Creates a connection to the Database. This is for Access, which is crap!
    • makeConnection

      public static Connection makeConnection​(String driver, String protocol, String server, String port, String database, String userName, String password, int type)
      Creates a connection to the Database.
    • printSQLValues

      public static void printSQLValues()
    • getMethodName

      public static String getMethodName​(String databaseName)
    • getVariableName

      public static String getVariableName​(String databaseName)
    • getVariableName

      public static String getVariableName​(String databaseName, boolean capFirstLetter)
    • formatNullableObject

      public static String formatNullableObject​(Object o)
    • formatNullableObject

      public static String formatNullableObject​(Object o, int type)
    • toEscapeMSSQL

      public static String toEscapeMSSQL​(String unformattedString)
    • toEscapeACCESS_SQL

      public static String toEscapeACCESS_SQL​(String unformattedString)
    • toEscapeSQL

      public static String toEscapeSQL​(String unformattedString)
    • beginTransaction

      public static void beginTransaction​(Statement stmt) throws SQLException
      Throws:
      SQLException
    • beginTransaction

      public static void beginTransaction​(Connection con) throws SQLException
      Throws:
      SQLException
    • commit

      public static void commit​(Statement stmt) throws SQLException
      Throws:
      SQLException
    • commit

      public static void commit​(Connection con) throws SQLException
      Throws:
      SQLException
    • rollback

      public static void rollback​(Statement stmt) throws SQLException
      Throws:
      SQLException
    • rollback

      public static void rollback​(Connection con) throws SQLException
      Throws:
      SQLException
    • formatBoolean

      public static String formatBoolean​(boolean b)
    • isAcceptableDatabaseString

      public static boolean isAcceptableDatabaseString​(String string)
      This is for none space single words, such as email, name, handle
    • getLike

      public static String getLike​(int databaseType)
    • getDatabaseStatusString

      public static final String getDatabaseStatusString​(int status)
      A convenience function to turn the int's into readable text for debuging.
      Parameters:
      status - The status to be translated
      Returns:
      The Text representation of static variable.
    • saveAll

      public static void saveAll​(DatabaseObject[] databaseObjects, Statement stmt) throws SQLException
      Throws:
      SQLException
    • close

      public static void close​(ResultSet rs)
    • close

      public static void close​(Statement stmt)
    • close

      public static void close​(Connection con)