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

Excel数据使用jdbc直接插入Mysql数据库

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import jxl.*;
public class ImportExcel {
public static void main(String[] args) {
File importExcel = new File("D:\\test\\test.xls");
try {
// 数据库连接
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/datebaseTest?characterEncoding=UTF-8", "root", "");
PreparedStatement prep = conn
.prepareStatement("insert into importe (id,name) values (?,?)");
Workbook workBook = Workbook.getWorkbook(importExcel);
Sheet[] sheet = workBook.getSheets();
int sheet_i_num = 0;
String id = "";
String name = "";
if (sheet != null && sheet.length > 0) {
for (int sheetNum = 0; sheetNum < sheet.length; sheetNum++) {
sheet_i_num = sheet[sheetNum].getRows();
for (int rowNum = 1; rowNum < sheet_i_num; rowNum++) {
Cell[] cells = sheet[sheetNum].getRow(rowNum);
id = cells[0].getContents();
name = cells[1].getContents();

prep.setInt(1, Integer.parseInt(id));
prep.setString(2, name);
prep.executeUpdate();
System.out.println(id + "--------" + name);
}
}
}
workBook.close();
prep.close();
conn.close();
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
}
}
}
在mysql中建立数据表
CREATE TABLE importe (
Id int(11) NOT NULL auto_increment,
name varchar(50) default NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
______________________________________________________________________
向数据库中插入时间,将Excel中时间的格式dd/MM/yyyy插入数据库中,我认为这需要格式转换为yyyy-MM-dd格式。
对于Mysql 建立表格
create table test(
id int(10),
datafrom date);
在Excel中,建立表格,保存为2003的Excel。
Id Data
1 25/11/2009
2 26/11/2009
3 27/11/2009
import java.io.File;
import java.sql.Connec


相关文档:

MySQL的密码设置

http://www.3d308.cn/article.asp?id=37
shell> mysql -u root mysql
mysql> Update user SET Password=PASSWORD('new_password')
           Where user='root';
mysql> FLUSH PRIVILEGES; ......

MySQL免安装配置(Vista)

MySql版本:mysql-noinstall-5.1.43-win32
系统:Vista
在C:\myProgram Files\mysql-5.1.43-win32(解压的目录)下将选一个配置文件(my-small.ini)编辑:
1.在[client]下添加:
   default-character-set=utf8                ......

用mysql作openldap的后台数据库

etting up OpenLDAP with MySQL backend
用mysql作后台数据库安装openldap
author: TBONIUS
OpenLDAP is an X.500 Lightweight Directory Access Server used for
centralized authentication and directory lookups. ......

MySQL中增加新用户并对其赋予相应权限的办法

(1)格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"
 
(2)例1、增加一个用户user_1密码为123,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令:
mysql> grant select,insert,update,delete on *.* to use ......

mysql重装问题解决方案

mysqlfront连接时出现“程序注册时间到期了,程序将被限制在淡模式下运行”这个问题时,不用重装,只需在Mysql Front 的帮助菜单项的登记里输入以下Mysql Front的注册码即可。
MysqlFront注册码如下:
0hjwKUddagvS41S9TIb8EwuiXwo4+dlr
t8z9sq/YRlP9e0zTx7jVlriD8bWlwoJM
TRlllybJ0+wce5rRZGaMBnWJH5H0/Pwv ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号