⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 returnaction.java

📁 JAVA图书管理软件源码,是我师兄亲自参与编的毕业设计
💻 JAVA
字号:
package com.ivan.menu;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import com.ivan.db.Database;

public class ReturnAction 
{

	public static boolean returnBook(Vector<String[]> v)
	{
		Vector<String> borrowInfoSql = new Vector<String>();
		Vector<String> bookItemSql = new Vector<String>();
		
//		value[0]=mode.getValueAt(i, 0).toString();//bookid
//		value[1]=mode.getValueAt(i, 3).toString();//borrow time
//		value[2]=mode.getValueAt(i, 4).toString();//reader id
//		value[3]=mode.getValueAt(i, 6).toString();//out day
//		value[4]=mode.getValueAt(i, 7).toString();//out money
		
		String[] value = new String[5];
		for(int i=0;i<v.size();i++)	
		{
			value=v.get(i);
			borrowInfoSql.add("update borrowinfo set returnTime=sysdate()," +
					       "outDays='"+value[3]+"',money='"+value[4]+"' " +
					       	" where readerId='"+value[2]+"' and bookId='"+value[0]+"' and " +
					       	" borrowTime='"+value[1]+"'" );
			bookItemSql.add("update bookitem set status='未借出' where bookId='"+value[0]+"'");
		}
		
		Connection connection;		
		connection = Database.getConnection();            //建立数据库连接
		Statement stmt=null;
		
		try 
		{
			stmt= connection.createStatement();
			for(int i=0;i<borrowInfoSql.size();i++)	
			{
				stmt.executeUpdate(borrowInfoSql.get(i));
				stmt.executeUpdate(bookItemSql.get(i));
				
			}
			   
			return true;
		} 
		catch (SQLException e) 
		{
			try 
			{
				connection.rollback();
			} 
			catch (SQLException e1)
			{
				
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		
		finally
		{
			try 
			{
				connection.close();
			} 
			catch (SQLException e)
			{
				
				e.printStackTrace();
			}
		}
		
		return false;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -