复利计算--结对(链接数据库)
2016-04-19 01:17
357 查看
结对同伴博客园地址:
:郭志豪
http://home.cnblogs.com/u/gzh13692021053/
项目完成估计与实际完成对比表如下所示:
查阅相关资料链接:http://www.2cto.com/kf/201405/298386.html
github地址:https://github.com/Sub-key/1/tree/master/fulitest
主要代码:
把数据输入到mysql中:
public void dmysql (double P,int N,double R,int M,double F) throws ClassNotFoundException, SQLException{
String name = "root";
String pwd = "123456";
String url = "jdbc:mysql://localhost_3306/fulisql";
try{
Class.forName("com.mysql.jdbc.Driver");
//Class.forName("org.gjt.mm.mysql.Driver");
}catch(ClassNotFoundException e)
{
e.printStackTrace();
}
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/fulisql", "root", "123456");
Statement stmt = conn.createStatement();
String sql1 = "insert into fuli(P,N,R,M,F) values(?,?,?,?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql1);
pstmt.setDouble(1,P);
pstmt.setInt(2,N);
pstmt.setDouble(3,R);
pstmt.setInt(4,M);
pstmt.setDouble(5,F);
//pstmt.executeUpdate();
pstmt.executeUpdate();
stmt.close();
conn.close();
}
}
从数据库中输出数据:
public class test1_1 {
public static void server(double P,int N, double R, int M, double F)
throws SQLException, ClassNotFoundException {
String name = "root";
String pwd = "123456";
String url = "jdbc:mysql://localhost:3306/fulisql";
Class.forName("com.mysql.jdbc.Driver");
// Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/fulisql", "root", "123456");
Statement stmt = conn.createStatement();
String sql = "select * from fuli";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
P = rs.getDouble("P");
N = rs.getInt("N");
R = rs.getDouble("R");
M = rs.getInt("m");
F = rs.getDouble("F");
System.out.println(P + "\t" + R + "\t" + N + "\t" + M + "\t" + F);
}
rs.close();
stmt.close();
conn.close();
}
}
实验结果:
合作照:
:郭志豪
http://home.cnblogs.com/u/gzh13692021053/
项目完成估计与实际完成对比表如下所示:
估计查找资料时间(h) | 3 |
时间查找资料时间(h) | 4 |
估计团队讨论时间(h) | 2 |
时间团队讨论时间(h) | 2 |
估计编程时间(h) | 5 |
实际编程时间(h) | 7 |
估计完成时间(h) | 9 |
实际完成时间(h) | 12 |
github地址:https://github.com/Sub-key/1/tree/master/fulitest
主要代码:
把数据输入到mysql中:
public void dmysql (double P,int N,double R,int M,double F) throws ClassNotFoundException, SQLException{
String name = "root";
String pwd = "123456";
String url = "jdbc:mysql://localhost_3306/fulisql";
try{
Class.forName("com.mysql.jdbc.Driver");
//Class.forName("org.gjt.mm.mysql.Driver");
}catch(ClassNotFoundException e)
{
e.printStackTrace();
}
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/fulisql", "root", "123456");
Statement stmt = conn.createStatement();
String sql1 = "insert into fuli(P,N,R,M,F) values(?,?,?,?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql1);
pstmt.setDouble(1,P);
pstmt.setInt(2,N);
pstmt.setDouble(3,R);
pstmt.setInt(4,M);
pstmt.setDouble(5,F);
//pstmt.executeUpdate();
pstmt.executeUpdate();
stmt.close();
conn.close();
}
}
从数据库中输出数据:
public class test1_1 {
public static void server(double P,int N, double R, int M, double F)
throws SQLException, ClassNotFoundException {
String name = "root";
String pwd = "123456";
String url = "jdbc:mysql://localhost:3306/fulisql";
Class.forName("com.mysql.jdbc.Driver");
// Class.forName("org.gjt.mm.mysql.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/fulisql", "root", "123456");
Statement stmt = conn.createStatement();
String sql = "select * from fuli";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
P = rs.getDouble("P");
N = rs.getInt("N");
R = rs.getDouble("R");
M = rs.getInt("m");
F = rs.getDouble("F");
System.out.println(P + "\t" + R + "\t" + N + "\t" + M + "\t" + F);
}
rs.close();
stmt.close();
conn.close();
}
}
实验结果:
合作照:
相关文章推荐
- PostgreSQL数据库的安装与PostGIS的安装(转)
- Php连接及读取和写入mysql数据库的常用代码
- MYSQL数据库自动定期备份和恢复工具
- Servlet学习笔记(二)---连接Mysql
- sqlite3 读写二进制数据
- Mysql学习(一) windows7 mysql5.7.12 noinstall安装
- python安装与使用redis的方法
- SQL Server删除表及删除表中数据的方法
- MySQL实现MYISAM表批量压缩的方法
- mysql表优化、分析、检查和修复的方法详解
- mysql关联子查询的一种优化方法分析
- MySQL切分查询用法分析
- MySQL子查询用法实例分析
- MySQL中字符串索引对update的影响分析
- 史上最全互联网分布式缓存技术视频教程(redis、memcached、ssdb)
- 命令行创建mysql数据库、用户、授权、导入SQL脚本
- Oracle连接慢
- MySQL压缩表
- Oracle表压缩技术
- 渗透学习day1