把连接数据库的信息放入Hibernate属性文件中,如用户名、密码,然后读取,大家给个例子啊
解决方案 »
- <a href="del.jsp?id="+rs.getInt(1)+">中的加号是什么意思
- 用过 hibernate 一定要进
- 请教SQL问题!
- J2EE应用快速开发暨自动代码生成器实现详解
- JSF中的h:commandLink如何传递参数?
- 求助
- 各位大虾知道我的机子8080端口哪去了呢?
- 菜鸟请问下, Resin与Tomcat有什么区别?
- hibernate的一个问题
- 这错,求大神解决java.lang.ClassFormatError: Invalid pc in LineNumberTable in class file
- hibernate的.lang.NullPointerException错误
- 谁和小弟说说jsp的作用域.他们的区别!详细点啊…………小弟没分哦!
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="connection.username">sa1</property>
<property name="connection.url">jdbc:jtds:sqlserver://localhost</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="myeclipse.connection.profile">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.password"></property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
hibernate.dialect=org.hibernate.dialect.SQLServerDialecthibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriverhibernate.connection.url=jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=数据库名hibernate.connection.username=用户名hibernate.connection.password=密码...
建议采用xml格式的配置文件。xml配置文件可以直接对映射文件进行配置,由Hibernate自动加载,而properties文件则必须在程序中通过编码加载映射文件。
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="connection.username">dccuser</property>
<property name="connection.url">
jdbc:oracle:thin:@127.0.0.1:1521:ora9i
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">用户名</property>
<property name="connection.password">密码</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<mapping resource="com/hibernate/model/Deptinfo.hbm.xml" />
</session-factory></hibernate-configuration>
hibernate.dialect=org.hibernate.dialect.SQLServerDialect hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver hibernate.connection.url=jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=数据库名 hibernate.connection.username=用户名 hibernate.connection.password=密码
....
我想知道具体是怎么来读取这些配置,给点代码啊
<property name="location"><value>classpath:hibernate.properties</value></property>
</bean>