Guest User

Untitled

a guest
Apr 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Context path="/A">
  3. <Resource auth="Container"
  4. driverClassName="com.mysql.jdbc.Driver"
  5. maxActive="100"
  6. maxIdle="30"
  7. maxWait="10000"
  8. minEvictableIdleTimeMillis="30000"
  9. name="jdbc/db1"
  10. timeBetweenEvictionRunsMillis="20000"
  11. type="javax.sql.DataSource"
  12. password="xxx"
  13. url="jdbc:mysql://192.xxx/db1"
  14. username="xxx"/>
  15.  
  16. <Resource auth="Container"
  17. driverClassName="com.mysql.jdbc.Driver"
  18. maxActive="100"
  19. maxIdle="30"
  20. maxWait="10000"
  21. minEvictableIdleTimeMillis="30000"
  22. name="jdbc/db2"
  23. timeBetweenEvictionRunsMillis="20000"
  24. type="javax.sql.DataSource"
  25. password="xxx"
  26. url="jdbc:mysql://192.xxx/db2"
  27. username="xxx"/>
  28.  
  29. </Context>
  30.  
  31. <resource-ref>
  32. <res-ref-name>jdbc/db1</res-ref-name>
  33. <res-type>javax.sql.DataSource</res-type>
  34. <res-auth>Container</res-auth>
  35. <res-sharing-scope>Shareable</res-sharing-scope>
  36. </resource-ref>
  37.  
  38.  
  39. <resource-ref>
  40. <res-ref-name>jdbc/db2</res-ref-name>
  41. <res-type>javax.sql.DataSource</res-type>
  42. <res-auth>Container</res-auth>
  43. <res-sharing-scope>Shareable</res-sharing-scope>
  44. </resource-ref>
  45.  
  46. <?xml version="1.0" encoding="UTF-8"?>
  47.  
  48. <beans xmlns="http://www.springframework.org/schema/beans"
  49. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  50. ........
  51.  
  52. <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  53. <property name="dataSource" ref="dataSource"/>
  54. <property name="jpaAdapter">
  55. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  56. <property name="showSql" value="true"/>
  57. <property name="generateDdl" value="false"/>
  58. <property name="database" value="MYSQL" />
  59. <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/>
  60. </bean>
  61. </property>
  62. <property name="jpaDialect">
  63. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect">
  64. </bean>
  65. </property>
  66.  
  67.  
  68. <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  69. <property name="jndiName" value="java:comp/env/jdbc/db1" />
  70. </bean>
  71. <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  72. <property name="entityManagerFactory" ref="entityManagerFactory"/>
  73. <property name="dataSource" ref="dataSource"/>
  74. </bean>
  75.  
  76. <bean id="dataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
  77. <property name="jndiName" value="java:comp/env/jdbc/db2" />
  78. </bean>
  79. <bean id="transactionManager1" class="org.springframework.orm.jpa.JpaTransactionManager">
  80. <property name="entityManagerFactory" ref="entityManagerFactory"/>
  81. <property name="dataSource" ref="dataSource1"/>
  82. </bean>
  83.  
  84. ......
  85. </beans>
  86.  
  87. String query = "SELECT r FROM Details r WHERE r.date =:ddmm";
  88. Query createQuery = super.createQuery(query);
  89. createQuery.setParameter("ddmm", ddmm.format(date));
  90. List<Tb2> list = createQuery.getResultList();
  91. System.out.println("list are "+ list);
  92.  
  93. Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'db1.tb2' doesn't exist
Add Comment
Please, Sign In to add comment