3.向t_phone_info表插入一条数据,rowkey 为0001,列族名为’cf1’,列名为‘name’,值为’Tom’;
时间: 2023-10-29 16:04:21 浏览: 26
.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBUtil {
private static final String URL = "jdbc:mysql://localhost:3306/shop";
private static final String USERNAME = "root";
private static final String PASSWORD = "123456";
public static Connection getConnection() throws SQLException {
return DriverManager.getConnection(URL, USERNAME, PASSWORD);
}
}
```
查询商品信息(ProductDAO.java):
```
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class ProductDAO {
public static List<Product> findAll() throws SQLException {
List<Product> productList = new ArrayList<>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = DBUtil.getConnection();
stmt = conn.prepareStatement("SELECT * FROM product");
rs = stmt.executeQuery();
while(rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
double price = rs.getDouble("price");
Product product = new Product(id, name, price);
productList.add(product);
}
} finally {
if(rs != null) rs.close();
if(stmt != null) stmt.close();
if(conn != null) conn.close();
}
return productList;
}
}
```
5. 集成支付和物流查询功能
这里可以集成支付宝、微信支付或其他支付平台的API,实现网站支付功能。可以集成快递100等物流查询平台的API,实现订单物流查询功能。
6. 部署上线
将网站部署到Tomcat等服务器上,保证网站的稳定运行。