java web开发

来源:互联网 发布:知乎精彩回答合集 编辑:程序博客网 时间:2024/05/08 01:48

环境配置:

1. 【OS]】:

    win7 32

2. 【IDE】:

    MyEclipse Enterprise Workbench
    Version: 8.5
    Build id: 8.5-20100319

3. 【DB 】:

    Server version: 5.6.21-log MySQL Community Server (GPL)

4. 【driver】:

     mysql-connector-java-5.1.17-bin.jar

==================================================================

【表结构】:


【数据库操作】:

public class sql_helper {public static void main(String[] args) {// 驱动程序名//不固定,根据驱动String driver = "com.mysql.jdbc.Driver";// URL指向要访问的数据库名******String url = "jdbc:mysql://localhost:3306/td_sale";// MySQL配置时的用户名String user = "testuser";// Java连接MySQL配置时的密码******String password = "1234";try {// 加载驱动程序Class.forName(driver);// 连续数据库Connection conn = DriverManager.getConnection(url, user, password);if (!conn.isClosed())System.out.println("Succeeded connecting to the Database!");// statement用来执行SQL语句Statement statement = conn.createStatement();// 要执行的SQL语句id和content是表review中的项。String sql = "select *from user";ResultSet rs = statement.executeQuery(sql);// 输出id值和content值while (rs.next()) {System.out.println(rs.getString("id") + "\t"+ rs.getString("num") + "\t"+ rs.getString("name") +"\t"+ rs.getString("address") +"\t"+ rs.getString("birthday") +"\t"+ rs.getString("sex"));}rs.close();conn.close();} catch (ClassNotFoundException e) {System.out.println("Sorry,can`t find the Driver!");e.printStackTrace();} catch (SQLException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}}}

【结果输出】:


【jsp读取java中的数据】

<%@page import="com.sale.sql.*"%> <%    sql_test v =new sql_test();    v.data_visit();%>


也可采用select * from 表名 into outfile "c:\\文件路径";进行查询;进行导出表中的数据为文本文件格式。 也可以采用select * from 表名 into outfile "c:\\stu_t.txt" lines terminated by '\r\n';进行查询,导出。


String, Stringbuffer, StringBuilder 

http://www.cnblogs.com/dolphin0520/p/3778589.html


truncate table user;
http://blog.csdn.net/piaolankeke/article/details/6272214


批量导入数据到mysql:

 LOAD DATA LOCAL INFILE 'E:\\workspace\\data\\user.txt' INTO TABLE user_t FIELDS TERMINATED BY '\t';

数据表拷贝:

insert user(num,name,address,birthday,sex) select * from user_t;

表结构:






画图

http://tech.it168.com/j/2007-09-29/200709291132796.shtml


http://blog.csdn.net/chenssy/article/details/9773797

http://my.oschina.net/lionel45/blog/174022

jsp操作xml

http://www.cnblogs.com/wanglei-134/p/3182685.html
读文件
http://goby2008.iteye.com/blog/711569

jsp 导入数据出现乱码、及多一个?的处理方式

http://blog.csdn.net/jackpk/article/details/5702964

http://gundumw100.iteye.com/blog/520481


0 0
原创粉丝点击