CLOB Integration
CLOB Integration
- Subject: CLOB Integration
- From: Jérémy DE ROYER <email@hidden>
- Date: Fri, 27 Feb 2009 13:37:56 +0100
Hello,
As we wanted to avoid storing xhtml content for an enterprise object
in our file system (backuping and replicating the database is easier
than the file system AND the database), we tried to store it in the
database.
To avoid using EOF (for memory and speed purposes), we started
accessing the database directly using the methods above : the "xhtml"
rows are not in the EOMODEL.
It's works great (thanks to willInsert, willUpdat, hasInserted and
hasUpdated methods).
We started using a single connection shared for the application but
we had concurrent acces problem. So we created a connection each time
we had to access the database.
This works great for small needs but for huge ones, we encontered
problems with Frontbase that was using 100 % CPU event if will kill
the Java App.
I think the problem comes from the number of connections we have to
open.
Question : do we have to go back and use file system or is there a
better solution using the connection (example given using EOF
connection) instead of creating lots of connection ?
Jérémy
public static synchronized Connection getConnection() throws
SQLException {
Connection connection = null;
byte tryCount = 0;
while (connection == null)
{
try {
connection = DriverManager.getConnection
(IndeXysStartupParametres.startupParametres
().getValeurForStartupParametre
(IndeXysStartupParametres.URL_DATABASE), null, null);
log.debug("Connection successfull");
}
catch (SQLException e) {
if (++tryCount > 5)
{
throw e;
}
else
{
connection = null;
e.printStackTrace();
log.error("Unable to connect to database. Retrying in 1 second");
try {
Thread.sleep(1000);
}
catch (InterruptedException ie) {
}
}
}
}
return connection;
}
AND
public static void updateContentForColumnTableAndId(String
contentIn, String columnNameIn, String tableIn, String idIn) throws
SQLException {
if (! IndeXysUtilitiesForString.isStringNullOrEmpty(idIn))
{
Connection myConnection = null;
try {
myConnection = getConnection();
Statement myStatement = myConnection.createStatement();
myStatement.executeUpdate("UPDATE \"" + tableIn + "\" SET \"" +
columnNameIn + "\" = '" +
IndeXysUtilitiesForString.stringContentIfNotNull(contentIn).replace
("'","''") + "' WHERE \"id\" = " + idIn);
myConnection.commit();
}
catch (SQLException e) {
log.error("updateContentForColumnTableAndId / SQLException /
columnNameIn >" + columnNameIn);
log.error("updateContentForColumnTableAndId / SQLException /
tableIn >" + tableIn);
log.error("updateContentForColumnTableAndId / SQLException / idIn
>" + idIn);
e.printStackTrace();
}
catch (NullPointerException e) {
log.error("updateContentForColumnTableAndId / SQLException /
columnNameIn >" + columnNameIn);
log.error("updateContentForColumnTableAndId / SQLException /
tableIn >" + tableIn);
log.error("updateContentForColumnTableAndId / SQLException / idIn
>" + idIn);
e.printStackTrace();
}
if (myConnection != null)
{
try {
myConnection.close();
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden