简体   繁体   中英

Connecting Java Web Application to Oracle Database

<bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName"
                  value="????????????????????" />        
     <property name="url"
                  value="???????????????????????"/>
        <property name="username" value="root" />
        <property name="password" value="" />
    </bean>

I am not able to figure out what should go in driver class name value and url vale. I have downloaded Oracle sql developer and oracle 11 g.But i am not sure how to configure it to my java application

Driver class name:- oracle.jdbc.driver.OracleDriver
URL :- jdbc:oracle:thin:@(hostname):(port number):(database name)

<bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName"
                  value="oracle.jdbc.driver.OracleDriver" />        
     <property name="url"
                  value="jdbc:oracle:thin:@(hostname):(port number):(database name)"/>
        <property name="username" value="root" />
        <property name="password" value="" />
</bean>

Your qustion is not clear if you are using Spring framework there are two type of Data source handling technique

Method 1 you need to configure data source in your application server

  <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:jboss/datasources/OracleDS" /> <property name="cache" value="false"/> <property name="lookupOnStartup" value="false"/> <property name="proxyInterface" value="javax.sql.DataSource"/> </bean> 

Method 2

  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:OMQA" /> <property name="username" value="root" /> <property name="password" value="password" /> </bean> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM