Spring connect to Oracle and Sql Server Database simply (Part 2)

Tuesday, December 1st, 2015 (0 Comment)

Continue part 1 – Spring connect to Mysql Database, we will change configuration to spring connect to Oracle and Sql Server.

You need to click here to practice and after that modify some config files to connect to Oracle and Ssql Server.

A. To config Spring connect to Oracle

edit porn.xml for spring connect to oracle:

replace mysql’s driver

to oracle’ driver

edit servlet-config-jdbc.xml:

  • 123.123.1.123: your oracle’s ip
  • 1521: default oracle’s port
  • SID: SID or instance of oracle
  • hibernate.default_schema: username to login database (oracle’s schema)
  • other parameters: you can review part 1 – spring connect mysql

modify class entity Room.java to mapping database

  • with oracle: add line 13 and line 18 to auto create Sequence. if you create trigger auto increased id number replace sequence, you do not need add line 13 and line 18

This is the easy way how to Spring connect to Oracle, and following for sql server.

B. To config Spring connect to SQL Server

edit porn.xml:

replace mysql’s driver

to sqlserver’ driver

edit servlet-config-jdbc.xml:

  • servername: instance or name that you set during install sql server
  • you should install sql server to practice (should not install sql express)

modify class entity Room.java to mapping database

  • line 16: add type primary key auto increased id number of sql server

build and run the same part 1 (http://lvtutorial.com/spring-mvc/spring-connect-mysql-database-simply-part-1.html)

Config Spring connect to Oracle and Sql server the same Mysql, only different some files config as: servlet-config-jdbc.xml, porn.xml and entity class.

Tags: , , , ,

Related Posts

spring
How to create quartz spring dynamic in database
spring
Spring mvc mongodb crud users roles
spring
Java spring mvc tutorial on lvtutorial.com
spring
Angularjs spring mvc crud example

Related Posts

spring
How to create quartz spring dynamic in database
spring
Spring mvc mongodb crud users roles
spring
Java spring mvc tutorial on lvtutorial.com
spring
Angularjs spring mvc crud example

Leave a Reply

Your email address will not be published. Required fields are marked *