twitter
    !! Tell us what you want to Learn / Know !!
Showing posts with label how to connect with database from tomcat. Show all posts
Showing posts with label how to connect with database from tomcat. Show all posts

JDBC

Example:
    Same procedure applies to any database just change the below details accordingly.

Database : POINTBASE

driverClassName=com.pointbase.jdbc.jdbcUniversalDriver

url=jdbc:pointbase:server://localhost:9092/surendraDB

schema: surendraDB

username = surendra

password = surendra

Step1:
     Create a table with name sample and insert values into it.

            create table sample (usernam  varchar(30), pass varchar(30));

            insert into sample values (‘username’,’password’);

Step2:
    Copy the pbclient57.jar from the database lib to $CATALINA_HOME/lib

Step3:
     Now open context.xml file from the following location

     $CATALINA_HOME/conf

     Add the following lines before </context>

     <Resource name="jdbc/testmultidb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="surendra" password="surendra"          driverClassName="com.pointbase.jdbc.jdbcUniversalDriver"
               url="jdbc:pointbase:server://localhost:9092/surendraDB"/>


Step4:
       Now deploy the sample (download) application and try accessing it using the following url

      http://localhost:<PORT>/suren


Enter the details that you have entered in step1 while creating a table.

If everything went ok you should see the below screen.


If you are unable to see anything, make sure your database is running.