public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
center(java.awt.Component c)
Centers an awt component w.r.t.
|
static java.lang.String |
checkSQLName(java.lang.String string, int maxStringLength)
Checks for any illegal characters in a SQL name.
|
static java.sql.Connection |
connect(java.lang.String host, java.lang.String sid, java.lang.String port, java.lang.String user, java.lang.String passwd, java.lang.String mode, int rowPref)
Establishes an Oracle JDBC connection to the specified database.
|
static double[] |
convert(java.lang.String str)
Converts a string of coordinates into a double array.
|
static java.lang.String |
enquoteColumnName(java.sql.Connection conn, java.lang.String columnName)
Enquotes a column name.
|
static java.lang.String |
enquoteNameSQLName(java.sql.Connection conn, java.lang.String name)
Returns the ENQUOTE_NAME formatted String for the SQL name If the Oracle JDBC is present, use the new OracleStatement.enquoteIdentifier API in the JDK8 JDBC.
|
static java.lang.String |
enquoteTableName(java.sql.Connection conn, java.lang.String tableName)
Enquotes a table name with or without schema name which is separated by ".".
|
static java.lang.String |
getConnStr(java.lang.String mode, java.lang.String host, java.lang.String port, java.lang.String sid)
connects to the database using supplied information.
|
static java.lang.String |
getDBVersion(java.sql.Connection conn)
Gets the version of the database connected.
|
static java.lang.String |
getJDBCDriverVersion(java.sql.Connection conn)
Gets the oracle JDBC driver version string.
|
static java.awt.Shape |
getShape(double[] coords, boolean close)
converts the coordinate array into a GeneralPath shape.
|
static boolean |
isGeodetic(int srid)
Using an Oracle convention to determin if a srid is geodetic.
|
static boolean |
isPre9i(java.sql.Connection conn)
Determin if a database is pre-9i version.
|
static void |
main(java.lang.String[] args) |
static java.awt.geom.Rectangle2D.Double |
mbr(double[] coords) |
static java.lang.String |
qualifiedSQLName(java.sql.Connection conn, java.lang.String name)
Checks if the specified name is a qualified SQL name.
|
static byte[] |
readFile(java.lang.String f) |
static java.util.ArrayList |
splitBy(java.lang.String str, java.lang.String delim)
gets an array list of strings that are separated by delimiters such as commas
|
public static double[] convert(java.lang.String str)
public static java.util.ArrayList splitBy(java.lang.String str, java.lang.String delim)
str
- the input string to be tokenizeddelim
- the delimiter to be used in tokenizing the stringpublic static java.awt.Shape getShape(double[] coords, boolean close)
public static java.awt.geom.Rectangle2D.Double mbr(double[] coords)
public static byte[] readFile(java.lang.String f) throws java.io.IOException
java.io.IOException
public static java.sql.Connection connect(java.lang.String host, java.lang.String sid, java.lang.String port, java.lang.String user, java.lang.String passwd, java.lang.String mode, int rowPref)
host
- name of the host machine where the database runssid
- instance id of the databaseport
- which port the database is listening atuser
- the database user to connect topasswd
- the database user's passwordmode
- the connection mode; possible values are "thin", "oci" or "oci8". If null value is supplied the default "oci8" mode is attempted.rowPref
- the row prefetch to be set with the connection. If a value less than or equal to zero is supplied, the defualt value of 32 will be used for this connection.public static java.lang.String getJDBCDriverVersion(java.sql.Connection conn)
public static java.lang.String getDBVersion(java.sql.Connection conn)
public static boolean isPre9i(java.sql.Connection conn)
public static boolean isGeodetic(int srid)
public static java.lang.String getConnStr(java.lang.String mode, java.lang.String host, java.lang.String port, java.lang.String sid)
If user requires OCI-mode connection but failed, then a "Thin" mode connection is automatically attempted.mode
,host
,port
,sid
mode
- the mode of connection. It could either be a THIN or an OCI connection. THIN is slower but pure java, while OCI is faster but requires Oracle OCI library.host
- the host where the database is located.port
- the port where the database instance listens (default is 1521)sid
- the instance id of the database.public static void center(java.awt.Component c)
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.Exception, java.sql.SQLException
java.io.IOException
java.lang.Exception
java.sql.SQLException
public static java.lang.String checkSQLName(java.lang.String string, int maxStringLength) throws java.sql.SQLException
string
- input stringmaxStringLength
- maximum length for input stringjava.sql.SQLException
- An exception is thrown if the input string contains any illegal characters or exceeds the maximum lengthpublic static java.lang.String qualifiedSQLName(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input namejava.sql.SQLException
- A SQLexception is thrown if the dbms_assert.qualified_sql_name failedpublic static java.lang.String enquoteNameSQLName(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input namejava.sql.SQLException
public static java.lang.String enquoteTableName(java.sql.Connection conn, java.lang.String tableName) throws java.sql.SQLException
conn
-tableName
-java.sql.SQLException
public static java.lang.String enquoteColumnName(java.sql.Connection conn, java.lang.String columnName) throws java.sql.SQLException
conn
-columnName
-java.sql.SQLException