在oracle中要注意數據庫是用SID還是服務名。因爲兩者的在Spring裏是不同的。如下:
格式一: Oracle JDBC Thin using a ServiceName:
jdbc:oracle:thin:@//<host>:<port>/<service_name>
Example: jdbc:oracle:thin:@//172.0.0.1:7003/orcl
注意這裏的格式,@後面有//, 這是與使用SID的主要區別。
這種格式是Oracle 推薦的格式,因爲對於集羣來說,每個節點的SID 是不一樣的,但是SERVICE_NAME 確可以包含所有節點。
格式二: Oracle JDBC Thin using an SID:
jdbc:oracle:thin:@<host>:<port>:<SID>
Example: jdbc:oracle:thin:172.0.0.1:1521:sid
格式三:Oracle JDBC Thin using a TNSName:
jdbc:oracle:thin:@<TNSName>
Example: jdbc:oracle:thin:@TND