1,234
edits
Changes
no edit summary
[[category: NexJ Express PostgreSQL]][[Category:NexJ_Express_Development]][[category: NexJ Express]]
Package: <code>nexj</code>:Create <code>postgresql.connections</code> using NexJ Studio:Edit <code>default.config</code> to use PostgreSQL:Edit all <code>*.connections</code> files to use PostgreSQL == 1=Configure UnitTests for more than one Database=== <!- -== Setup the postgresql-connection ==
For testing the connection, the 'AllTests.java' is being used.
: Installed the <code> Installer version Version 9.0.1-1</code> from list of [http://www.enterprisedb.com/products/pgdownload.do#windows PostgreSQL downloads].: Installed the <code> JDBC3 Postgresql Driver, Version 9.0-801 </code> @ http://jdbc.postgresql.org/download.html and added it to the libraries in JDK
:: The driver class which is being used for NexJ Express Model is: <code> org.postgresql.xa.PGXADataSource </code>
:: The driver is loaded from RelationalDatabaseFragment.java and RelationalDatabase.java
: After all properties are loaded, it creates the connection through Connection Factory files.
===- ModificationsFiles to Configure==={|class="collapsible collapsed" style="border-style:solid;border-width:thin;border-color:black"!align="left" style="background-color:SteelBlue; font-weight:bold;border-style:solid;border-width:thin;padding: 2px 2px 2px 2px;"| '''NOTE''': Changes Done to MySQL adapterthese files are involved with ''' |1- |Port''', which should be: When a connection is first established5432, this initial SQL statement and '''2- Driver package''' that should execute in MySQL, which is not the case for PostgreSQL, so it was commented out:::change to <source lang=javacode>/* MySQLAdapterorg.postgresql.xa.java *PGXADataSource </code>: srcpublic String getInitialSQL():: system.dstype { StringBuffer buf = new StringBuffer(); buf:: DatabaseTool.append("set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES')"); java // allow using doublequote when quoting column names in "CREATE TABLE" statementsThis file calles SQLSchemaMangerFactory.java and creates the connection buf:: RelationalDatabase.append(";set optimizer_search_depth = 0"); java // let DB automatically decide on how long it takes to examine plans, improves long planning sessionsSets the default properties for the supported drivers buf:: RelationalDatabaseFragment.append(";set max_sort_length = ").append(Math.max(MAX_VARCHAR_PRECISION, MAX_VARBINARY_PRECISION)); java // set TEXT/BLOB minimum sorting length to be same as cutoff between varchar/text return buf.toString(); }</source>Sets the custom fragment properties for the supported drivers: Also the same line should be commented out : Driver type and some other properties in postgresql_createJDBCInfo.sql script, which is being used to create tables in the database 'test':java::<source lang=SQLSchemaManagerFactory.java> /* nexj/core/persistence/sql/etc/postgresql_create.sql */Sets the connection for the particular adapter typeset sql_mode = concat(@@sql_mode, ',ANSI_QUOTES');</source>: test: After activating the connection, the database is locked: AllTests.java: In MySQL, the storage engine is set to a transactional safe engine such as [http://wwwdefault.wikivs.comconfig /wiki/MySQL_vs_PostgreSQL#MySQLchange to these four files are:InnoDB InnoDB], whereas adapter="PostgreSQL has a single built in engine" port="5432":: postgresql. So, changes needed to be done to this scriptconnection ::filestorage.connections::<source lang=java>create table testfilestoragefragment.Account(connections id binary(16) not null, contactId binary(16) not null, account Type varchar(16) character set utf8 not null, funds double null, constraint Account_PK primary key(id) )engine=innoDB;</source--> |}