日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

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

該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓

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

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

ex?=?ex.getNextException();

}

}

catch(Exception?ex?)

{

ex.printStackTrace();

}

}

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

{

try

{

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

String?url?=?"jdbc:odbc:shop";???????????????????//指定數(shù)據(jù)源名

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

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";????//創(chuàng)建獲取顧客交易記錄的SQL語句

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

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

}

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)????//獲取指定顧客的交易記錄的結(jié)果集

{

try

{

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

String?url?=?"jdbc:odbc:shop";???????????????????//指定數(shù)據(jù)源名

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

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?+?"'";????//創(chuàng)建獲取指定顧客交易記錄的SQL語句

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

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

}

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)????//刪除指定顧客的交易記錄

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。