Open main menu

CDOT Wiki β

Changes

NexJ Express Connecting to PostgreSQL

1,966 bytes added, 20:30, 26 January 2014
no edit summary
<big><big> PostgreSQL Adapter for NexJ - Create Test Environment </big></big>{{NexJ_Express IndexAdmon/obsolete}}
[[category: NexJ Express PostgreSQL]][[Category:NexJ_Express_Development]][[category: NexJ Express]] ==Task Summary == {| border="1" cellpadding="4" cellspacing="2" style="border: 1px solid black;border- Setup collapse:collapse;"|-! Task! Status|- | Install the postgresqlPostgreSQL Server| DONE|- | Install PostgreSQL driver| DONE|- | Add code to connect to server| DONE|-| Create Script for Test database| DONE |-| Test connection to the server| DONE|-| Configure UnitTests for multiple DB's| |} == Task Details ===== Install PostgreSQL ===For testing the connectionDownload: <code>Version 9.0</code> from list of [http://www.enterprisedb.com/products/pgdownload.do#windows PostgreSQL downloads]. === Install PostgreSQL JDBC3 driver ===Download: <code> JDBC3 Postgresql Driver, the 'PostgreSQLAdapterTestVersion 9.0-801 </code> @ http://jdbc.postgresql.java' is being usedorg/download.html * <br/>Install: Copy driver to <code>[[PostgreSQL_Adapter-jdk folder]/jre/lib/ext</code> === Code: Add PostgreSQL Driver ===Package: <code>nexj.core.persistance.sql</test-envcode>:Create <code>PostgreSQLAdapter.java</code> by extending <code>SQLAdapter</code>:Create <code>PostgreSQLSchemaManager.java</code> by extending <code>SQLSchemaManager</code> :Edit <code>RelationalDatabase.java</code>:Edit <code>RelationalDatabaseFragment.java</code>:Edit <code>SQLSchemaManagerFactory.java</code> Package: <code>nexj.core.meta.sys</code>:Edit <code>system.dstypes</code> === SQL Scripts ===Package: <code>nexj.core.persistence.sql.script</todo |TODOs]]code>: Create and Configure the work* <code>postgresql_setup.sql</code>* <code>postgresql_drop.sql</code>* <code>postgresql_insert.sql</code>* <code>postgresql_upd_addr.sql</wscode>* <code>postgresql_upd_cont.sql</code> === UnitTest: Test Connectivity to database ===Package: <code>nexj.core.persistance.sql</testcode>:Create <code>PostgreSQLAdapterTest.java</code> by extending <code>SQLAdapterTest</code>:Create <code>PostgreSQLSchemaManagerTest.java</code> by extending <code>SQLSchemaManagerTest</code> Package: <code>nexj</code>:Create <code>postgresql.configconnections</code> using NexJ Studio:: for now, the contents of Edit <code>default.config is changed </code> to postgresql specifications instead of mysqluse PostgreSQL: walkEdit all <code>*.connections</code> files to use PostgreSQL ===Configure UnitTests for more than one Database=== <!-through lines from 214-218 in SQLManagementConnectionFactory.java: Walk== Setup the postgresql-through properties and see what exactly is needed to be authorized to connect to 'test' databaseconnection ==: Make sure For testing the model connects to connection, the PostgreSQL using user 'testAllTests.java' - Break @ SQLManagerFactoryis being used.java Line:122: Figure out why there is the exception (unable to lock Installed the <code> Installer version Version 9.0.1-1</code> from list of [http://www.enterprisedb.com/products/pgdownload.do#windows PostgreSQL store for the adapter - Break @ SQLDataTestdownloads].java Line:443* Done: 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
: Metadata is loaded from the particular driver
::
props.setProperty(XMLMetadataLoader.CONNECTIONS_URL_PROPERTY, "/nexj/" + sAdapter.toLowerCase(Locale.ENGLISH) + ".connections"); // sets the properties to postgresql.connection
</source>
: After all properties are loaded, it creates the connection through Connection Factory files.
===Files to Configure==='''NOTE''': Changes to these files are involved with '''1-Port''', which should be: Configured the work/ws/core/test/nexj/5432, and '''2- Driver package''' that should change to <code> org.postgresql.connectionxa.PGXADataSource </code>: src: Configured : system.dstype: Configured DatabaseTools: DatabaseTool.java // This file calles SQLSchemaMangerFactory.java and creates the connection: Configured : RelationalDatabase.java SQLRAConnectionFactory// Sets the default properties for the supported drivers:: RelationalDatabaseFragment.java// Sets the custom fragment properties for the supported drivers: Configured : Driver type and some other properties in JDBCInfo.java: Configured : SQLSchemaMangerFactorySQLSchemaManagerFactory.java // Sets the connection for the particular adapter type: test=== 2- Create a PostgreSQL database through some scripts===:: AllTests.java: postgresql_setup: default.sql ==config // change to these four files are: adapter= 3- Create the extended "PostgreSQL source files ==" port="5432": PostgreSQLAdapter: postgresql.javaconnection : PostgreSQLSchemaManger: filestorage.java === 4- Create the extended PostgreSQL test files ===connections: PostgreSQLAdapterTest:filestoragefragment.javaconnections: PostgreSQLSchemaMangerTest.java-->