日期:2014-05-16 浏览次数:20486 次
java 语言开发,tomcat服务器,使用框架ssh
具体详情:
1,spring配置文件中
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>classpath:database.properties</value> </property> </bean> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>${jdbc.datasource}</value> </property> </bean>
?2,database.properties配置文件中内容为:
jdbc.datasource=java:comp/env/jdbc/cqa
?
3,tomcat服务器中,在conf\Catalina\localhost下创建文件 xxx.Xml,配置数据源及项目路径信息
<Context path="/cqa" reloadable="true" docBase="D:/workspace/cqa/WebRoot" workDir="work/Catalina/localhost/cqa"> <Resource name="jdbc/cqa" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:cqa/cqa@111.112.0.203:1521:ora9i" username="xx" password="yy" maxIdle="30" maxWait="5000" maxActive="100"/> </Context>
?4,tomcat lib目录中增加驱动jar包ojdbc14.jar