public class CommonDB extends Object
| Constructor and Description |
|---|
CommonDB(DBConnection dbCon,
String fileName,
boolean showQueries)
This constructor establishes a connection to a Database and loads the
queryfile.
|
CommonDB(DBConnection dbCon,
String fileName,
boolean showQueries,
boolean isSwing)
This constructor establishes a connection to a Database and loads the
queryfile.
|
CommonDB(String knownDBURL,
String userId,
String passWd,
String fileName,
boolean showQueries,
boolean isSwing)
A standard Constructor, which uses MySQL per default.
It establishes a connection to a Database and load the queryfile. |
CommonDB(String knownDBURL,
String userId,
String passWd,
String fileName,
boolean showQueries,
String dbName,
boolean isSwing)
A standard Constructor, which uses MySQL per default.
It establishes a connection to a Database and load the queryfile. |
CommonDB(String driverClass,
String dbUrl,
String userId,
String passWd,
String fileName,
boolean showQueries,
boolean isSwing)
This constructor establishes a connection to a Database and loads the
queryfile.
|
CommonDB(String driverClass,
String dbUrl,
String userId,
String passWd,
String fileName,
boolean showQueries,
String dbName,
boolean isSwing)
This constructor establishes a connection to a Database and loads the
queryfile.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addQuery(String keyName,
String query)
Adds a query to the queryfile
|
void |
changeQueryFile(String newQueryFileName)
This methods loads a new queryfile, if neccesary.
|
void |
changeQueryFileCatched(String newQueryFileName)
This methods loads a new queryfile, if neccesary.
|
ResultSet |
executePartOfAQueryWithResults_ResultSet(String query,
Vector questionMarks,
int startPosition,
int endPosition,
String primkey)
Executes a query on a DB, that will return a result (SELECTs).
Very similar to the executeQueryWithResults-method, but: Returns only a part of the data (useful for guge DBs) Attention: To get all, including the very last entry of the table, you have to add 1 to the endPosition! But not during the normal run, only at the very last one! |
ResultSet |
executePartOfAQueryWithResults_ResultSetCatched(String query,
Vector questionMarks,
int startPosition,
int endPosition,
String primkey)
Executes a query on a DB, that will return a result (SELECTs).
Very similar to the executeQueryWithResults-method, but: Returns only a part of the data (useful for guge DBs) Attention: To get all, including the very last entry of the table, you have to add 1 to the endPosition! But not during the normal run, only at the very last one! |
Vector<String[]> |
executePartOfAQueryWithResults(String query,
Vector questionMarks,
int startPosition,
int endPosition,
String primkey)
Executes a query on a DB, that will return a result (SELECTs).
Very similar to the executeQueryWithResults-method, but: Returns only a part of the data (useful for guge DBs) Attention: To get all, including the very last entry of the table, you have to add 1 to the endPosition! But not during the normal run, only at the very last one! |
Vector |
executePartOfAQueryWithResultsCatched(String query,
Vector questionMarks,
int startPosition,
int endPosition,
String primkey)
Executes a query on a DB, that will return a result (SELECTs).
Very similar to the executeQueryWithResults-method, but: Returns only a part of the data (useful for guge DBs) Attention: To get all, including the very last entry of the table, you have to add 1 to the endPosition! But not during the normal run, only at the very last one! |
void |
executeQueryWithoutResults(String query,
Vector questionMarks)
Executes a query on a DB, that will not return any results (such as
INSERTS, and so on).
|
void |
executeQueryWithoutResultsCatched(String query,
Vector questionMarks)
Executes a query on a DB, that will not return any results (such as
INSERTS, and so on).
|
ResultSet |
executeQueryWithResults_ResultSet(String query,
Vector questionMarks)
Executes a query on a DB, that will return a result (SELECTs).
|
ResultSet |
executeQueryWithResults_ResultSetCatched(String query,
Vector questionMarks)
Executes a query on a DB, that will return a result (SELECTs).
|
Vector<String[]> |
executeQueryWithResults(String query,
Vector questionMarks)
Executes a query on a DB, that will return a result (SELECTs).
|
Vector |
executeQueryWithResultsCatched(String query,
Vector questionMarks)
Executes a query on a DB, that will return a result (SELECTs).
|
int |
getHighestPrimaryKey(String tableName,
String primkey)
Returns the highest number of an primary key - you can see, that this
method needs an integer or so as a primary key.
|
int |
getHighestPrimaryKeyCatched(String tableName,
String primkey)
Returns the highest number of an primary key - you can see, that this
method needs an integer or so as a primary key.
|
int |
getLowestPrimaryKey(String tableName,
String primkey)
Very similiar to the getMaxCountOfRowsInTableByPrimaryKey-method.
But: This method returns the lowest value. |
int |
getLowestPrimaryKeyCatched(String tableName,
String primkey)
Very similiar to the getMaxCountOfRowsInTableByPrimaryKey-method.
But: This method returns the lowest value. |
String |
getPrimaryKeyName(String tableName)
Returns the Primary Key to a given table on the DB, that this object has
a connection to.
|
String |
getPrimaryKeyNameCatched(String tableName)
Returns the Primary Key to a given table on the DB, that this object has
a connection to.
|
String |
getQuery(String key)
Returns the query to a given key.
|
String |
getQueryFileName()
This method returns the name/path of the queryfile.
|
String |
getReEncodeType()
This methods returns the actual re-encoding Type.
|
String |
getStandardizedString(String stringType,
String toEncode,
boolean isSwing) |
String |
getStandardizedStringCatched(String stringType,
String toEncode,
boolean isSwing)
Use this method if you have UTF-8 encoded Strings which a stored in a DB
via ISO-LATIN-1 (ISO-8859-1).
That means, this method will give you the UTF-8 String back, which was automatically ISO encoded by the DB. |
boolean |
isReEncode()
This method shows you the actual state of the reEncode variable.
True: The Strings have to be re-encoded. False: There's no need for re-encoding. |
boolean |
isShowQueries()
Returns the status of the attribute, that allows to show the queries,
when the queryfile is changed...
|
boolean |
isSwing()
This method shows you the bool value of the isSwing variable.
|
void |
setIsSwing(boolean isSwing)
This method is very important for re-encoding, because for that you
need to know, if you're running re-encoding from console or from
Java.Swing.
Also you will need this, if you want to show DialogBoxes for the Errors or not. |
void |
setReEncode(boolean reEncode)
This one is very important, when you know, that your Strings in a DB are
stored via ISO-LATIN-1, but you know, that tey are containing UTF-8 data.
In this case you need to set reEncode to 'true'! If not, it's per default set to false, but maybe then you have to reset it to false again. Never forget to use the setReEncodeType method, too! |
void |
setReEncode(boolean reEncode,
String type)
This one is very important, when you know, that your Strings in a DB are
stored via ISO-LATIN-1, but you know, that tey are containing UTF-8 data.
In this case you need to set reEncode to 'true'! If not, it's per default set to false, but maybe then you have to reset it to false again. In this method you can specify the type of reencoding by your own. |
void |
setReEncodeType(String type)
This method is to set the encoding type, from which you want to
re-encode.
Never forgett to specify, when you want to use rencoding! |
void |
setShowQueries(boolean showQueries)
This method is to set, if you want to list the queries or not (if you
change the queryfile...)
|
void |
storeQueryFile(String comment)
This will store the queryfile with possible new queries.
But: be carefull, this might change the order of the queryfile so that it will not any longer be easy to read this file. |
void |
storeQueryFileCatched(String comment)
This will store the queryfile with possible new queries.
But: be carefull, this might change the order of the queryfile so that it will not any longer be easy to read this file. |
public CommonDB(String knownDBURL, String userId, String passWd, String fileName, boolean showQueries, String dbName, boolean isSwing)
knownDBURL - The URL to the DB (simple, w/o the additional Java-stuff).userId - The user for the connection.passWd - The users password.fileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutdbName - The database its name.isSwing - to specify wheter it is Swing based or notpublic CommonDB(String knownDBURL, String userId, String passWd, String fileName, boolean showQueries, boolean isSwing)
knownDBURL - The URL to the DB (simple, w/o the additional Java-stuff).userId - The user for the connection.passWd - The users password.fileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutisSwing - to specify wheter it is Swing based or notpublic CommonDB(String driverClass, String dbUrl, String userId, String passWd, String fileName, boolean showQueries, String dbName, boolean isSwing)
driverClass - The driverClass in Java to establish the connection to the DB.dbUrl - The URL to this DB.userId - The user for the connection.passWd - The users password.fileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutdbName - The database its name.isSwing - to specify wheter it is Swing based or notpublic CommonDB(String driverClass, String dbUrl, String userId, String passWd, String fileName, boolean showQueries, boolean isSwing)
driverClass - The driverClass in Java to establish the connection to the DB.dbUrl - The URL to this DB.userId - The user for the connection.passWd - The users password.fileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutisSwing - to specify wheter it is Swing based or notpublic CommonDB(DBConnection dbCon, String fileName, boolean showQueries, boolean isSwing)
dbCon - The DBConnection-Object, that holds the connectivity data for
the DBfileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutisSwing - to specify wheter it is Swing based or notpublic CommonDB(DBConnection dbCon, String fileName, boolean showQueries)
dbCon - The DBConnection-Object, that holds the connectivity data for
the DBfileName - The name of the queryfile - or better: the path!showQueries - True, if you want to list the queries, the queryfile contains,
to StandartOutpublic void setReEncode(boolean reEncode)
reEncode - True, if the Strings from the DB need to be re-encodes.public void setReEncode(boolean reEncode,
String type)
reEncode - type - public boolean isReEncode()
public void setIsSwing(boolean isSwing)
isSwing - True, if you're runnging from Java.Swing.public boolean isSwing()
public void setReEncodeType(String type)
type - The type from which you want to re-encode. (ISO-8859-1 for
example)public String getReEncodeType()
public void changeQueryFileCatched(String newQueryFileName)
newQueryFileName - The name, or better the path, of the new queryfilepublic void changeQueryFile(String newQueryFileName) throws FileNotFoundException, IOException
newQueryFileName - The name, or better the path, of the new queryfileFileNotFoundExceptionIOExceptionpublic String getQueryFileName()
public void setShowQueries(boolean showQueries)
showQueries - public boolean isShowQueries()
public void addQuery(String keyName, String query)
keyName - The name of the key to add to the filequery - The query that relates on the keypublic void storeQueryFileCatched(String comment)
comment - If you want to add a comment to beginn of the queryfile...public void storeQueryFile(String comment) throws IOException
comment - If you want to add a comment to beginn of the queryfile...IOExceptionpublic String getPrimaryKeyNameCatched(String tableName)
tableName - The tablename, where you want to get the primary's key name.public String getPrimaryKeyName(String tableName) throws SQLException
tableName - The tablename, where you want to get the primary's key name.SQLExceptionpublic int getHighestPrimaryKeyCatched(String tableName, String primkey)
tableName - The name of the table where to look on.primkey - The name of the primary key (use the getPrimaryKeyName-method)public int getHighestPrimaryKey(String tableName, String primkey) throws SQLException
tableName - The name of the table where to look on.primkey - The name of the primary key (use the getPrimaryKeyName-method)SQLExceptionpublic int getLowestPrimaryKeyCatched(String tableName, String primkey)
tableName - The name of the table where to look on.primkey - The name of the primary key (use the getPrimaryKeyName-method)public int getLowestPrimaryKey(String tableName, String primkey) throws SQLException
tableName - The name of the table where to look on.primkey - The name of the primary key (use the getPrimaryKeyName-method)SQLExceptionpublic void executeQueryWithoutResultsCatched(String query, Vector questionMarks)
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementspublic void executeQueryWithoutResults(String query, Vector questionMarks) throws SQLException
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementsSQLExceptionpublic Vector executeQueryWithResultsCatched(String query, Vector questionMarks)
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementspublic Vector<String[]> executeQueryWithResults(String query, Vector questionMarks) throws SQLException, Exception
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementsSQLExceptionExceptionpublic ResultSet executeQueryWithResults_ResultSetCatched(String query, Vector questionMarks)
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementspublic ResultSet executeQueryWithResults_ResultSet(String query, Vector questionMarks) throws SQLException
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementsSQLExceptionpublic Vector executePartOfAQueryWithResultsCatched(String query, Vector questionMarks, int startPosition, int endPosition, String primkey)
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementspublic Vector<String[]> executePartOfAQueryWithResults(String query, Vector questionMarks, int startPosition, int endPosition, String primkey) throws SQLException, Exception
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementsSQLExceptionExceptionpublic ResultSet executePartOfAQueryWithResults_ResultSetCatched(String query, Vector questionMarks, int startPosition, int endPosition, String primkey)
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementspublic ResultSet executePartOfAQueryWithResults_ResultSet(String query, Vector questionMarks, int startPosition, int endPosition, String primkey) throws SQLException
query - The query, that have to be executed on the DBquestionMarks - A Vector-object, that contains the data, that have to be
entered for prepared statementsSQLExceptionpublic String getStandardizedStringCatched(String stringType, String toEncode, boolean isSwing)
stringType - The type from which to reencode. (ISO-8859-1 for example)toEncode - The String to re-encode to UTF-8.isSwing - True, if you run this method from Java.Swing, false if not.Copyright © 2013. All rights reserved.