神啊!!!哪位大虾救命啊!!!SSH整合之后怎么掉JNDI数据源啊,俺用的tomcat6.0 还有6.0没有管理界面配置JNDI的数据源么??!!!急啊!!!!急啊!!!!急啊!!!!急啊!!!!
看完这个在告诉偶:
tomcat的context.xml中加入
<resource name="test" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="sa" password="120010"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test">
</resource>
web.xml中也加入了:
<resource-ref>
<res-ref-name>test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
spring配置文件中也加入了:
<bean id="dataSourcetarget"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/test"></property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource">
<ref bean="dataSourcetarget" />
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
</bean>
为啥运行的时候DAO里面的HibernateTemplate老是空的,就是说数据源注入失败了,为什么啊!!!!小弟邮箱是[email protected]哪位大虾发个完整的能运行的啊,小弟来生做牛做马#@$@#$...
看完这个在告诉偶:
tomcat的context.xml中加入
<resource name="test" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="sa" password="120010"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test">
</resource>
web.xml中也加入了:
<resource-ref>
<res-ref-name>test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
spring配置文件中也加入了:
<bean id="dataSourcetarget"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/test"></property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource">
<ref bean="dataSourcetarget" />
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
</bean>
为啥运行的时候DAO里面的HibernateTemplate老是空的,就是说数据源注入失败了,为什么啊!!!!小弟邮箱是[email protected]哪位大虾发个完整的能运行的啊,小弟来生做牛做马#@$@#$...
<Resource name="jdbc/student" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/student">
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>sa</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:sqlserver://192.168.0.213:1433;databaseName=Student</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>8</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>
</ResourceParams>
web.xml中也加入了:
<resource-ref>
<description>Student</description>
<res-ref-name>jdbc/student </res-ref-name>
<res-type>javax.sql.DataSource </res-type>
<res-auth>Container </res-auth>
</resource-ref>
spring配置文件中也加入了:
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/student"> </property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/com/koogames/stu/pojo/Student.hbm.xml</value></list>
</property></bean>