package com.huimv.receive.timer.test;

import java.sql.*;

public class TestConnection {
    public static void main(String[] args) throws ClassNotFoundException {

        String url = "jdbc:jtds:sqlserver://218.76.168.4:1433/CMTWeight"; // 使用 jTDS 连接字符串
        String user = "sa";
        String password = "jh@123";
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        try (Connection conn = DriverManager.getConnection(url, user, password)) {
            // 创建 Statement
            Statement stmt = conn.createStatement();
            // 创建 PreparedStatement（推荐）
            String sql = "select * from T_Standard where  F_BeginTime > '2025-04-18 00:00:00'";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            // 执行查询...
            ResultSet resultSet = pstmt.executeQuery();

            while (resultSet.next()) {

                TestWeight testWeight = new TestWeight(resultSet.getString("F_StdNo")
                        ,resultSet.getString("F_CarNo")
                        ,resultSet.getString("F_ProName")
                        ,resultSet.getString("F_Model")
                        ,resultSet.getString("F_unitFrom")
                        ,resultSet.getString("F_Load")
                        ,resultSet.getString("F_UnitTo")
                        ,resultSet.getString("F_UnLoad")
                        ,resultSet.getString("F_Transport")
                        ,resultSet.getString("F_Driver")
                        ,resultSet.getString("F_Memo")
                        ,resultSet.getString("F_Type")
                        ,resultSet.getDouble("F_Number")
                        ,resultSet.getDouble("F_Gross")
                        ,resultSet.getDouble("F_Tare")
                        ,resultSet.getDouble("F_Net")
                        ,resultSet.getDouble("F_Deduct")
                        ,resultSet.getDouble("F_Fact")
                        ,resultSet.getDouble("F_Deduct2")
                        ,resultSet.getDouble("F_Fact2")
                        ,resultSet.getDouble("F_Price")
                        ,resultSet.getDouble("F_Money")
                        ,resultSet.getString("F_BeginTime")
                        ,resultSet.getString("F_EndTime")

                );
//                System.out.println(resultSet.getDate("F_BeginTime"));

                System.out.println(testWeight.toString());
                System.out.println();
            }

        } catch (Exception  e) {
            e.printStackTrace();
        }
    }

    //  url: jdbc:jtds:sqlserver://218.76.168.4:1433/CMTWeight
    //    username: sa
    //    password: jh@123
    //#    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    //    driver-class-name: net.sourceforge.jtds.jdbc.Driver
}