在你的配置文件中配置如下信息
<bean id="fltSessionFactory" class="orgspringframeworkormhibernate3annotationAnnotationSessionFactoryBean">
<property name="dataSource" ref="fltDataSource" />
<property name="packagesToScan" value="comxxxxxxxxxxxxxx"/>
<property name="hibernateProperties">
<props>
<!- 你要的配置 ->
<prop key="hibernatedialect">orghibernatedialectOracle10gDialect</prop>
<prop key="hibernateformat_sql">true</prop>
<prop key="hibernateshow_sql">true</prop>
<prop key="hibernatehbm2ddlauto">update</prop>
<prop key="hibernatequeryfactory_class">orghibernatehqlastASTQueryTranslatorFactory</prop>
<prop key="hibernateconnectionuseUnicode">true</prop>
<prop key="hibernateconnectioncharacterEncoding">UTF-8</prop>
<prop key="hibernatedefault_batch_fetch_size">16</prop>
<prop key="hibernateuse_sql_comments">false</prop>
<prop key="hibernatejdbcbatch_size">20</prop>
<prop key="hibernatejdbcfetch_size">30</prop>
<prop key="hibernategenerate_statistics">false</prop>
<prop key="hibernateautoReconnect">true</prop>
<prop key="hibernatecglibuse_reflection_optimizer">true</prop>
<prop key="hibernateconnectionrelease_mode">auto</prop>
<prop key="hibernatecurrent_session_context_class">orgspringframeworkormhibernate3SpringSessionContext</prop>
<prop key="hibernatecacheuse_query_cache">true</prop>
<prop key="hibernatecacheuse_second_level_cache">true</prop>
<prop key="hibernatecacheprovider_class">orghibernatecacheSingletonEhCacheProvider</prop>
<prop key="javaxpersistencevalidationmode">none</prop>
</props>
</property>
</bean>
1)首先要有java连接oracle数据库的驱动类,下载好后导入到工程里
2)代码:
import javasql;
public class JDBCTest {
/
@param args
@throws ClassNotFoundException
/
public static void main(String[] args)
throws ClassNotFoundException, SQLException{
//1准备参数
String ip = "192168026";
String sid = "tarena";
String port = "1521";
String dbUser = "openlab";
String dbPassword = "open123";
String driver
= "oraclejdbcdriverOracleDriver";
//2构造驱动实例
ClassforName(driver);
//3创建连接
//连接字符串是固定的形式,oracle的形式:
String url
= "jdbc:oracle:thin:@"
+ ip + ":" + port + ":" + sid;
Connection conn
= DriverManagergetConnection
(url, dbUser, dbPassword);
//4执行SQL语句
String sql = "select id, password, name from user_sd1104 " +
"where id = 1001 and password = '1234'";
Statement stmt = conncreateStatement();
ResultSet rs
= stmtexecuteQuery(sql);//执行sql语句
while(rsnext()){
int id = rsgetInt(1);
String pwd = rsgetString(2);
String name = rsgetString(3);
Systemoutprintln("welcome," + name);
}
rsclose();
stmtclose();
connclose();
}
}
换下方言,句号换成点
org。hibernate。dialect。Oracle12cDialect 新版的hibernate有
另外如果用jdbc:Oracle:thin:@localhost:1521:orcl,则会连接cdb,打开连接后会显示所有cdb用户(即全局用户),如果要显示某个pdb下的用户,则应重新配置连接,连接地址为jdbc:oracle:thin:@localhost:1521/pdborcl
那你这个程序的持久层也就是DAO层, *** 作数据访问的模块,里面会依赖数据库方言的oracle、mysql、sql server都有自己对应的方言dialect;需要切换的一般都是在配置文件里面的。
我们有学习小组也 希望一起学习进步 Java框架平台研发 378 437 335
换下方言,句号换成点
org。hibernate。dialect。Oracle12cDialect 新版的hibernate有
另外如果用jdbc:Oracle:thin:@localhost:1521:orcl,则会连接cdb,打开连接后会显示所有cdb用户(即全局用户),如果要显示某个pdb下的用户,则应重新配置连接,连接地址为jdbc:oracle:thin:@localhost:1521/pdborcl
以上就是关于hibernate3 oracle 11方言怎么设全部的内容,包括:hibernate3 oracle 11方言怎么设、怎样建立oracle数据库链接、我用hibernate框架的时候发现方言里面只有Oracle10g的,而我用的数据库是12c的等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)