Open main menu

CDOT Wiki β

Changes

NexJ Express Connecting to PostgreSQL

828 bytes added, 12:30, 2 December 2010
1- Setup the postgresql-connection
</source>
: After all properties are loaded, it creates the connection through Connection Factory files.
: When a connection is first established, this initial SQL statement should execute in MySQL, which is not the case for PostgreSQL, so it was commented out:
::
/* MySQLAdapter.java */
<source lang=java>
public String getInitialSQL()
{
StringBuffer buf = new StringBuffer();
 
buf.append("set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES')"); // allow using doublequote when quoting column names in "CREATE TABLE" statements
buf.append(";set optimizer_search_depth = 0"); // let DB automatically decide on how long it takes to examine plans, improves long planning sessions
buf.append(";set max_sort_length = ").append(Math.max(MAX_VARCHAR_PRECISION, MAX_VARBINARY_PRECISION)); // set TEXT/BLOB minimum sorting length to be same as cutoff between varchar/text
return buf.toString();
}
</source>
: After activating the connection, the database is locked.
1
edit