您的位置:首页 > 数据库

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

2016-04-19 01:17 357 查看
结对同伴博客园地址:

:郭志豪

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();
}

}

实验结果:





合作照:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: