Changes

Jump to: navigation, search

NexJ Express Connecting to PostgreSQL

2,781 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-collapse:collapse;"|-! Task! Status|- Setup | 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 ===Download: <code>Version 9.0</code> from list of [http://www.enterprisedb.com/products/pgdownload.do#windows PostgreSQL downloads]. === Install PostgreSQL JDBC3 driver ===Download: TODO<code> JDBC3 Postgresql Driver, Version 9.0-801 </code> @ http://jdbc.postgresql.org/download.html <br/>Install: Copy driver to <code>[jdk folder]/jre/lib/ext</code> === Code: Add PostgreSQL Driver ===Package: <code>nexj.core.persistance.sql</code>: Create and Configure the work<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</code>:Create * <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</code>:Create <code>PostgreSQLAdapterTest.java</code> by extending <code>SQLAdapterTest</code>:Create <code>PostgreSQLSchemaManagerTest.java</testcode> by extending <code>SQLSchemaManagerTest</code> 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 ===Configure UnitTests for nowmore than one Database=== <!--== Setup the postgresql-connection ==For testing the connection, the contents of default'AllTests.config java' is changed to postgresql specifications instead being used.: Installed the <code> Installer version Version 9.0.1-1</code> from list of mysql[http://www.enterprisedb.com/products/pgdownload.do#windows PostgreSQL downloads].: Configure Installed the work<code> JDBC3 Postgresql Driver, Version 9.0-801 </wscode> @ http:/core/testjdbc.postgresql.org/nexjdownload.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 </postgresqlcode>:: The driver is loaded from RelationalDatabaseFragment.java and RelationalDatabase.connectionjava: Metadata is loaded from the particular driver
::
<source lang=java>
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.
: Load the driver from RelationalDatabaseFragment.java===Files to Configure==='''NOTE''':Changes to these files are involved with '''1-Port''', which should be: The 5432, and '''2- Driver package ''' that is being imported: should change to <code> org.postgresql.jdbc3xa.Jdbc3PoolingDataSource PGXADataSource </code>:src: The package for simple connection not to a pool of connections, is: <code> orgsystem.postgresqldstype:: DatabaseTool.jdbc3java // This file calles SQLSchemaMangerFactory.Jdbc3SimpleDataSource </code>java and creates the connection === 2- Add PostgreSQL adapter type to related :: RelationalDatabase.java files===// Sets the default properties for the supported drivers: SQLSchemaMangerFactory: RelationalDatabaseFragment.java// Sets the custom fragment properties for the supported drivers === 3- Create a PostgreSQL database through :: Driver type and some scripts===other properties in JDBCInfo.java: postgresql_setup: SQLSchemaManagerFactory.sqljava // Sets the connection for the particular adapter type: test=== 4- Create the extended PostgreSQL source files ===: PostgreSQLAdapter: AllTests.java: PostgreSQLSchemaManger: default.java config // change to these four files are: adapter=== 5- Create the extended "PostgreSQL test files ==" port="5432":: postgresql.connection : PostgreSQLAdapterTest: filestorage.javaconnections: PostgreSQLSchemaMangerTest:filestoragefragment.javaconnections-->

Navigation menu