【实例简介】通过数据库的存储数据,用到了 Sql-Server-2_fat.jar
【实例截图】
【核心代码】
package eyou.dt;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;
public class DBUtils {
private PreparedStatement p;
private String spring;
private String Type;
private String summer;
private String fall;
private String winter;
private static ResultSet rs;
private static FileInputStream stat;
private static Object conn;
private static Object P;
static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static String url;
private static String user;
private static String pwd;
public static Connection getConnection() {
Connection con = null;
try {
Class.forName(DRIVER);
Properties property = new Properties();
try {
property.load(new FileInputStream("message.properties"));
url = property.getProperty("url");
user = property.getProperty("user");
pwd = property.getProperty("pwd");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
con = DriverManager.getConnection(url, user, pwd);
} catch (ClassNotFoundException e) {
System.out.println("连接失败");
e.printStackTrace();
} catch (SQLException e) {