oracle sql日期比较:
在今天之前:select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
在今天只后:select * from up_date where update > to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update >= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
精确时间:select * from up_date where update = to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
在某段时间内:select * from up_date where update between to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update > to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update >= to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
posted @
2007-09-07 16:29 forker 阅读(88440) |
评论 (6) |
编辑 收藏
MySql的备份可用命令mysqldump ,使用方法很简单,mysqldump -u 用户名 -p (密码) -h 主机名 数据库名
>路径/备份名.bak;同时也可以是用mysqldump到处数据结构(tablename.sql)和数据(tablename.txt)
mysqldump -u 用户名 -p (密码) -h 主机名 数据库名 tablename1 tablename2 >
back.sql或mysqldump -u 用户名 -p (密码) -h 主机名 数据库名 --tab 路径 --opt 数据库名.
那么还原可以mysql命令,mysql -u 用户名 -p (密码) -h 主机名 --one-database 还原数据库名 < 路径/备份名.bak,--one-database是指定要恢复的数据库.
(括号表示密码不先输入,在连接时在Enter password;若密码为空可缺省-p参数)
posted @
2007-09-06 17:08 forker 阅读(1290) |
评论 (0) |
编辑 收藏
安装有oracle数据库,创建数据库,总是要创建一个主键ID,唯一标示各条记录,但oracle不支持自动编号,所以还得创建一个SEQUENCE(序列)语句如
create sequence bign nocycle maxvalue 9999999999 start with 1;//增加数据
insert into table (ID,..) values(bign.nextval,..)
在hibernate中的映射文件可这么写
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence" >
<param name="sequence">bign</param>
</generator>
</id>
或
<id name="id" type="java.lang.Long" column="ID">
<generator class="increment" >
</id>
(increment 用与为long,short或者int类型生成唯一标示。只有在没有其他进程忘同一张表中插入数据时才能使用。在集群下不要使用)
posted @
2007-08-28 15:12 forker 阅读(4055) |
评论 (0) |
编辑 收藏
Hibernate加载其配置文件hibernate.properties和hibernate.cfg.xml,常用xml文件比较直观,方便管理,
Hibernate
是一个流行的开源对象关系映射工具,方便连接不同数据库,更换数据库,只要修改Hibernate配置文件,大度减少项目的维护。
完整的配置如下:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost/test</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="../*.hbm.xml"/>
</session-factory>
</hibernate-configuration>
常用数据库连接
MySql 3/4/5:
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
Microsoft SQLServer (via jTDS):
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sqlserver://localhost:1433/test;useCursors=true</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
IBM DB2:
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="connection.url">jdbc:db2://localhost:50000/test</property>
<property name="connection.username">db2inst1</property>
<property name="connection.password"></property>
Oracle:
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:test</property>
<property name="connection.username">ora</property>
<property name="connection.password"></property>
Informix:
<property name="dialect">org.hibernate.dialect.InformixDialect</property>
<property name="connection.driver_class">com.informix.jdbc.IfxDriver</property>
<property name="connection.url">jdbc:informix-sqli://localhost:1526/test:informixserver=server1</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.encoding">true</property>
Sybase (via jTDS):
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sybase://localhost:7100/test;useCursors=true</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
PostgreSQL:
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/test</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
MaxDB(SAPDB):
<property name="dialect">org.hibernate.dialect.SAPDBDialect</property>
<property name="connection.driver_class">com.sap.dbtech.jdbc.DriverSapDB</property>
<property name="connection.url">jdbc:sapdb://localhost/test</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
posted @
2007-08-21 10:01 forker 阅读(4115) |
评论 (0) |
编辑 收藏
最近在想能做点什么,该做点什么。
posted @
2007-08-15 16:54 forker 阅读(711) |
评论 (0) |
编辑 收藏