SQL2008 和Oracle 数据库在SSH中开发hibernate.cfg.xml配置区别(前者为SQL,后者为Oracle):
1.驱动:
com.microsoft.sqlserver.jdbc.SQLServerDriver
oracle.jdbc.driver.OracleDriver
2.URL:
jdbc:sqlserver://localhost:1433;DatabaseName=LS <!--LS为SQL数据库名称-->
jdbc:oracle:thin:@localhost:1521:orcl
3.user,password:(根据自己的数据库有不同的用户和密码)
“sa”“sa”
"scott" "tiger"
4.方言:
org.hibernate.dialect.SQLServerDialec
org.hibernate.dialect.Oracle10gDialect
5.包:
sqljdbc4.jar
ojdbc14.jar
6.实体注解中:
//注解int自动增长是SQL特有的,用IDENTITY
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int upno;
//int 可以用序列SEQUENCE
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
private int upno;
//UUID都可以用的:
@Id
@GeneratedValue(generator="pk")
@GenericGenerator(name="pk",strategy="uuid.hex")
private String orderID;
Ibatis中相关db.properties配置:
sqlserver:
target.database.url=jdbc:sqlserver://localhost:1433;DatabaseName=dedb(数据库名)
target.database.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
target.database.user=sa
target.database.password=2019
oracle:
source.database.url=jdbc:oracle:thin:@localhost:1521:orcl
source.database.driver=oracle.jdbc.driver.OracleDriver
source.database.user=sa
source.database.password=as
网友评论