I have a problem is how to use Spring 3 connect to Oracle database.
Please tell me detail because I'm a newbie
I'm use Eclipse Helios and Apache Tomcat
Thanks all
I have a problem is how to use Spring 3 connect to Oracle database.
Please tell me detail because I'm a newbie
I'm use Eclipse Helios and Apache Tomcat
Thanks all
Well...HOW do you intend to "connect" to the database? Do you intend to use JPA entities, and if so, what will you use as a JPA provider? EJB 3, Hibernate 3, JDO or what? If you don't use JPA will you use or not ORM at all? If not, are you going to use MyBatis SQL Mapper or will you use simple JDBC queries?
For each and every one of those choices, Spring 3 offers full support facilities so all you need to do is refer to the right section in the reference documentation.
When you've chosen your strategy and learned how to use it with Spring by studying the documentation and experimenting a bit on your own, then you can come back to the forum with more specific questions.
can you give me an ebook or document about this problem?
I find some ebook but it too hard to understand
Install SpringSource Tool Suite which has embedded tomcat and add in a jndi resouce to context.xml
In your spring configuration create a datasource referencing what you created in context.xmlCode:<Resource name="jdbc/yourIdentifer" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@dbserver:1521:dbschema" username="dbuser" password="dbpassword" maxActive="20" maxIdle="10" maxWait="-1"/>
I had to include ojdbc14.jar in the tomcat lib directory so it can use driverClassName="oracle.jdbc.OracleDriver"Code:<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jdbc/yourIdentifer" /> <property name="resourceRef" value="true" /> </bean>
HTH
To connect to oracle in your Spring project you need:
1. Add this dependency to your pom.xml:
2. Add dataSource to application context file:Code:<dependency> <groupId>com.oracle.jdbc</groupId> <artifactId>ojdbc14</artifactId> <version>9.2.0.8</version> <type>jar</type> <scope>compile</scope> </dependency>
3. Use this bean to set your DAOs:Code:<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="${datasource.url}" /> <property name="username" value="${datasource.user}" /> <property name="password" value="${datasource.password}" /> </bean>
If you have some questions feel free to aks.Code:<bean id="abstractJdbcDAO" abstract="true" class="org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport"> <property name="dataSource" ref="dataSource"></property> </bean>