易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP+MySql的时间处理

很久没有用Mysql了,发现小小的时间问题也遇到不少麻烦,呵呵
所以总结一下:
第一种:
Date time= new java.sql.Date(new java.util.Date().getTime());
第二种:
java 用PreparedStatement来setDate,用问号的形式给日期问号赋值
pstmt.setTimestamp(8, new Timestamp(System.currentTimeMillis()));  
pstmt.setDate(1, new java.sql.Date(date1.getTime()));
pstmt.setDate(2, new java.sql.Date(date2.getTime()));
第三:
其实向mysql数据库里插入时间字段也是很容易的,只要设置为java.util.Date类型后,以Hibernate的Pojo类对象为例,pojo.set(new java.util.Date());就可用了。
以下附录在网上找到的相关资料:
Mysql 与 java 的时间类型
           MySql的时间类型有             Java中与之对应的时间类型
                 date                                              java.sql.Date
             Datetime                                       java.sql.Timestamp
            Timestamp                                     java.sql.Timestamp
            Time              &


相关文档:

分享一个mysql类~

 
<?php
/**
* 操作mysql
的基础类,其它与mysql有关的类都继承于此基类
*
* 此class中的$table都是已经包含表前缀的完整表名
*
* ver 20090717
* 使用范例
* $db = new DB('localhost','root','password','database','utf8');
* $db->debug = true;
* $db->primaryKeys = array (
* 'table_1 ......

MySQL Migration Toolkit的使用

 MySQL Migration Toolkit是MySQL出的数据迁移工具(适用于MySQL5.0或以上),使用并不复杂,支持Oracle,Microsoft SQL Server,Microsoft Access,Sybase,MaxDB到MySQL之间的转换。以下实例是Oracle到MySQL的。
1. 安装jdk1.6
装完MySQL Migration Toolkit还需安装jdk1.6,需要jre1.5.0.8以上的支持。
2. 运行MySQL Mi ......

mysql alter 语句用法,添加、修改、删除字段

//主键
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//增加一个新列
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//删除列
alter table t2 drop column c;
//重命名列
......

solaris下mysql数据库字符集

solaris下mysql安装完毕后执行如下操作,可以修改数据库字符集,设置MySQL在Solaris上表名不区分大小写
1.拷贝文件如下:
cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf
把文件只读属性去掉
chmod +w my.cnf
 
2 设置mysql的字符集:在/etc/my.cnf中的mysqld段和client段加入代码:
 
[client]
de ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号