Evolution Hosting Database FAQ
Database FAQ Overview
This FAQ answers common questions related to working with databases
in the Evolution Hosting J2EE hosting environment.
Please feel free to contact support with any questions or suggestions.
Database FAQ Contents
- Database FAQ Overview
- Database FAQ Contents
- What databases does Evolution Hosting support?
- Evolution Hosting Tutorials
- What can you tell me about PostgreSQL?
- How do I access my database from my EJB account's application?
- How do I access my database from my JSP/Servlet account's application?
- How can I examine query performance in MS SQL Server?
- Which JDBC Drivers does Evolution Hosting use?
What databases does Evolution Hosting support?
Evolution Hosting offers a wide range of Database Servers, from the powerful open source database PostgreSQL,
to the industry standard Oracle. To view specific databases currently supported by Evolution Hosting, visit the
Price Quote page. Note that some databases require that a
license be uploaded by account holders - this is indicated in the Price Quote page when those databases are selected.
Evolution Hosting highly recommends PostgreSQL, which is gaining
popularity worldwide. Visit our PostgreSQL page for more information.
Evolution Hosting can host databases not currently listed in the Price Quote page; inquire
here.
Evolution Hosting Tutorials
Evolution Hosting has created tutorials for each application server platform that
contain full source code and complete build and deploy environments.
What can you tell me about PostgreSQL?
Evolution Hosting has two FAQ's related to PostgreSQL:
- General PostgreSQL FAQ
- PostgreSQL Windows Setup FAQ
How do I access my database from my EJB account's application?
Evolution Hosting allows hosted EJB applications acesss to their database via
J2EE Datasource reference. This technique works in any J2EE server and gets JDBC connection
information from a server's JNDI tree.
To see Evolution Hosting's JNDI entry that will be accessed by this example, go to the Evolution Hosting Console
and visit the Server | Connection Tab to see the ejip.datasource.name
property, which reads jdbc/DefaultDS . Note that you can change this property
to a different datasource name to match your existing application.
There are two places that need to be updated:
web.xml
The web.xml file is necessary to register the DataSource
defined within the global application in the desired web application (WAR). So, in
your WAR file's standard web.xml file, add this:
<resource-ref>
<res-ref-name>jdbc/DefaultDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
JSP / Servlet Code
Next, in the Servlet or JSP that require database access, enter this code
clip that accesses the datastore registered in the above
web.xml file. This code can also be used in a Servlet.
Note that the close() method on the connection actually returns it back
to the database pool for other resources to use.
//get DB connection...
Connection con = null ;
try
{
Context jndiCntx = new InitialContext();
out.println("Looking up jdbc/DefaultDS");
DataSource ds = (javax.sql.DataSource)jndiCntx.lookup("jdbc/DefaultDS");
out.println("Found. Connecting to jdbc/DefaultDS");
con = ds.getConnection();
if (con != null) {
out.println("Connection successful!");
}
}
catch (Exception ex)
{
out.println("getConnection failed. See error log for stack trace.");
}
finally
{
// close the Connection
try {
if (con!=null) con.close() ;
}
catch(SQLException sqle) {
con = null ;
}
}
How do I access my database from my JSP/Servlet account's application (Tomcat only)?
Currently the FastPool is used only in Evolution Hosting Tomcat server accounts. All other accounts use the
datasource method mentioned above. The FastPool is a 100% Java JDBC Connection
Pool.
To understand how to use the FastPool, visit the Evolution Hosting Tutorial page:
Sphinx.
How can I examine query performance in MS SQL Server?
Similar to most RDBMS systems, MS SQL Server allows query plan anlysis. This is done
by setting the SHOWPLAN_ALL option. Here is a simple select query with
query plan analysis activated:
SET SHOWPLAN_ALL on ;
select count(*) from CustomerTable ;
SET SHOWPLAN_ALL off ;
Which JDBC Drivers does Evolution Hosting use?
The Evolution Hosting hosting environment configures all database connection
settings for customer accounts. Customers access their database via the J2EE Datasource
, as explained above:
EJB
, and
JSP/Servlet.
No knowledge about the specific driver is necessary for deployment.
For development and testing purposes Evolution Hosting provides driver information, here:
- PostgreSQL
Evolution Hosting uses the free PostgreSQL JDBC Driver. More information
here.
- MS SQL Server
Evolution Hosting uses the free MS SQL Server JDBC Driver provided by Microsoft. More information
here.
- Oracle
Evolution Hosting uses the Oracle JDBC Driver. More information
here.
 |