日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

商店购物java程序_java操纵数据库-商店购物管理系统

發布時間:2025/3/19 windows 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 商店购物java程序_java操纵数据库-商店购物管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該樓層疑似違規已被系統折疊?隱藏此樓查看此樓

System.out.println("SQLState:??"?+?ex.getSQLState());

System.out.println("ErrorCode:?"?+?ex.getErrorCode());

ex?=?ex.getNextException();

}

}

catch(Exception?ex?)

{

ex.printStackTrace();

}

}

public?ResultSet?getDealInfo()???????????????????????//獲取顧客交易記錄的結果集

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");???//指定與數據庫連接使用JDBC-ODBC橋驅動程序

String?url?=?"jdbc:odbc:shop";???????????????????//指定數據源名

connection?=?DriverManager.getConnection(url);???//與數據源建立連接

String?sql?=?"select?cart_table.product_id,cart_table.buy_number,cart_table.customer_name,cart_table.customer_address";

sql+=",product_table.product_name?from?cart_table,product_table?where?cart_table.product_id=product_table.product_id";????//創建獲取顧客交易記錄的SQL語句

statement?=?connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);??//創建Statement接口實例

rs?=?statement.executeQuery(sql);????????????????//將數據存入結果集中

}

catch(SQLException?ex)

{

//捕捉異常

System.out.println("\nERROR:-----?SQLException?-----\n");

while?(ex?!=?null)

{

System.out.println("Message:???"?+?ex.getMessage());

System.out.println("SQLState:??"?+?ex.getSQLState());

System.out.println("ErrorCode:?"?+?ex.getErrorCode());

ex?=?ex.getNextException();

}

}

catch(Exception?ex?)

{

ex.printStackTrace();

}

return?rs;

}

public?ResultSet?getSingleDeal(String?customerName)????//獲取指定顧客的交易記錄的結果集

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");???//指定與數據庫連接使用JDBC-ODBC橋驅動程序

String?url?=?"jdbc:odbc:shop";???????????????????//指定數據源名

connection?=?DriverManager.getConnection(url);???//與數據源建立連接

String?sql?=?"select?cart_table.product_id,cart_table.buy_number,cart_table.customer_name,cart_table.customer_address";

sql+=",product_table.product_name?from?cart_table,product_table?where?cart_table.product_id=product_table.product_id?and?cart_table.customer_name='"?+?customerName?+?"'";????//創建獲取指定顧客交易記錄的SQL語句

statement?=?connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);??//創建Statement接口實例

rs?=?statement.executeQuery(sql);????????????????//將數據存入結果集中

}

catch(SQLException?ex)

{

//捕捉異常

System.out.println("\nERROR:-----?SQLException?-----\n");

while?(ex?!=?null)

{

System.out.println("Message:???"?+?ex.getMessage());

System.out.println("SQLState:??"?+?ex.getSQLState());

System.out.println("ErrorCode:?"?+?ex.getErrorCode());

ex?=?ex.getNextException();

}

}

catch(Exception?ex?)

{

ex.printStackTrace();

}

return?rs;

}

public?void?delSingleCustomerDeal(String?customerName)????//刪除指定顧客的交易記錄

總結

以上是生活随笔為你收集整理的商店购物java程序_java操纵数据库-商店购物管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。