The largest Interview Solution Library on the web


« Previous | 1 | 2 | 3 | Next »

Tomcat - Comparison of the datasource for common databases


Until now, we have seen how the datasource is confi gured on different databases. Let's quickly compare and fi nd out what are the different syntaxes for each database:
  • Oracle: The following mentioned code describes the datasource parameter for the Oracle database:
    <Resource name="jdbc/tomcat7" auth="Container"
    type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:oracle:thin:@127.0.0.1:1521:test"
    description="test database for tomcat 7"
    username="admin" password="admin" maxActive="20"
    maxIdle="10" maxWait="-1"/>

  • MySQL: The following mentioned code describes the datasource parameter for the MySQL database:
    <Resource name="jdbc/tomcat7" auth="Container"
    type="javax.sql.DataSource"
    driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://127.0.0.1:5432/tomcat7"
    username="tomcat7" password="tomcat" maxActive="20" maxIdle="10"
    maxWait="-1"/>

  • PostgreSQL: The following mentioned code describes the datasource parameter for the PostgreSQL database:
<Resource name="jdbc/tomcat7" auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://127.0.0.1:5432/tomcat7"
username="tomcat7" password="tomcat" maxActive="20" maxIdle="10"
maxWait="-1"/>
In the previous fi gure, we have defi ned each driverClassName, port, and JDBC driver for each database and tabulated to conclude that if you know the details for connectivity with the database, you can confi gure any new database very easily.

Every vendor has a predefi ned set of libraries through which you can connect to its database. If you need to connect to any other database, which is not mentioned here, then you can visit the vendor websites for support information.
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com