码迷,mamicode.com
首页 > 数据库 > 详细

复利计算--结对(链接数据库)

时间:2016-04-19 06:29:19      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

结对同伴博客园地址:

:郭志豪

http://home.cnblogs.com/u/gzh13692021053/

 

项目完成估计与实际完成对比表如下所示:

 

估计查找资料时间(h) 3
时间查找资料时间(h) 4
估计团队讨论时间(h) 2
时间团队讨论时间(h) 2
估计编程时间(h) 5
实际编程时间(h) 7
估计完成时间(h) 9
实际完成时间(h) 12

 

查阅相关资料链接: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://www.cnblogs.com/yzj666/p/5406599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!