2학년 때 프로젝트 과목으로 도서 관리 프로그램을 만들었던 코드를 정리했습니다.

 

 

자바가 미숙했기 때문에 코드나 동작 방식이 깔끔하지 못한 것은 감안하고 봐주시길 바랍니다.

 

디자인도 있지만(버튼 디자인 이미지, 아이콘 이미지 등) 팀 프로젝트였고 디자인은 제 파트가 아니었기 때문에 따로 올리지 않았습니다.

 

 

 

사용 대상 : 도서관 사서

 

동작 방식 : ISBN 등 책 정보를 프로그램에 등록하면 대출, 반납 등의 서비스를 이용할 수 있도록 동작

 

사용한 DBMS : MariaDB, 연결은 JDBC. 서버는 사용X

 

* 참고 : 중간 발표 때 프로그램에 책 등록 시 일일이 책의 정보를 입력해야한다면 불편하지 않겠는가, 실제 도서관은 바코드로 책 등록하지 않느냐 라는 질문이 들어와서 시립 도서관에 직접 가서 사서분께 시스템에 책 등록을 어떤 방식으로 하냐고 물어봤고 책 등록시에는 일일히 입력하며 대출, 반납에만 바코드를 쓰신다는 답변을 받았습니다.

 

 

 

BookDel.java  //책 삭제 

package book;

import java.awt.Color;
import java.awt.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import java.awt.Font;
import javax.swing.ImageIcon;

public class BookDel extends JFrame implements ActionListener{
	Connection con = null;
    Statement stmt = null;
    ResultSet  rs = null;
	JFrame f1 = new JFrame();
	JPanel pane = new JPanel();
	JButton b1, b2,b4,b5;
	JLabel l2,l5;
 JTextField jt4;
 Color b = new Color(47,71,81);

	public BookDel() {
			DBConn();
			MakerForm();
			
	}
	public void MakerForm() {
		f1.setTitle("도서 대여 프로그램");
		pane.setBackground(b);
		f1.setSize(1000,750);
		f1.setLocation(470,160);
		f1.setResizable(false);
		f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		pane.setLayout(null);
		
		l2 = new JLabel("ISBN을 정확히 입력해주세요");
		l2.setForeground(Color.WHITE);
		l2.setBounds(237, 179, 468, 30);
		l2.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l2);
		
		l5 = new JLabel("ISBN");
		l5.setForeground(Color.WHITE);
		l5.setBounds(100, 358, 60, 30);
		l5.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l5);
		
		
		jt4 = new JTextField();  //ISBN
		jt4.setBounds(214, 355, 331, 40);
		pane.add(jt4);
		
	
	
		b1 = new JButton();
		b1.setIcon(new ImageIcon(BookDel.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C3 copy copy.png")));
		b1.setForeground(Color.BLACK);
		b1.setFont(new Font("HY나무M", Font.PLAIN, 25));
		b1.setBounds(763, 32, 200, 60);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);
		b1.setContentAreaFilled(false);
		b1.addActionListener(this);
		pane.add(b1);
		
		b2 = new JButton();
		b2.setIcon(new ImageIcon(BookDel.class.getResource("/IMAGE/\uCC45 \uC0AD\uC81C2 copy copy.png")));
		b2.setForeground(Color.BLACK);
		b2.setFont(new Font("HY나무M", Font.PLAIN, 30));
		b2.setBounds(614, 352, 266, 60);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);
		b2.setContentAreaFilled(false);
		b2.addActionListener(this);
		pane.add(b2);
		
		

		f1.getContentPane().add(pane);
		
		
		
		f1.setVisible(true);
	}
	
	public void DBConn() {
		try {
			Class.forName("org.mariadb.jdbc.Driver");
//			System.out.println("드라이버 적재 성공");
			con = DriverManager.getConnection("jdbc:mariadb://127.0.0.1:3306/library","root","1234");
//			System.out.println("데이터베이스 연결 성공");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("드라이버를 찾을수 없습니다");
		} catch(SQLException e){
			e.printStackTrace();
			System.out.println("데이터베이스 연결 실패");
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == b2) {
			try {
				stmt = con.createStatement();
				String SQL = "DELETE FROM books WHERE ISBN='"+jt4.getText()+"'";
			stmt.executeUpdate(SQL);
			jt4.setText("");
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		}
		if(e.getSource() == b1) {
			f1.setVisible(false);
			Main.main.setVisible(true);
		}
		
		if(e.getSource() == b4) {
			f1.setVisible(false);
			JtableTestLast JTableTestLast = new JtableTestLast("jtabletest");
		}
		
		if(e.getSource() == b5) {
			f1.setVisible(false);
			Member f1 = new Member();
		}
		
	}
	
	public static void main(String[] args) {
		new Lent();
	}
	public void closeDatabase()
	{
		try
		{
			if( con != null )
			{
				con.close();
			}
			 
			if( stmt != null )
			{
				stmt.close();
			}
			 
			if( rs != null )
			{
				rs.close();
			}
		}
		catch (SQLException e)
		{
			System.out.println("[닫기 오류]\n" +  e.getStackTrace());
		}
	}
}

 

 

BookEnter.java  // 책 등록

package book;
import java.awt.Color;
import java.awt.Font;
import java.awt.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class BookEnter extends JFrame implements ActionListener{
	Connection con = null;
    Statement stmt = null;
    ResultSet  rs = null;
	JFrame f1 = new JFrame();
	JPanel pane = new JPanel();
	JButton b1, b2,b3;
	JLabel l1,l2,l3,l4,l5,l6,l7,l8;
 JTextField jt1, jt2,jt3, jt4, jt5,jt6,jt7;
 Color b = new Color(47,71,81);

	public BookEnter() {
			DBConn();
			MakerForm();
			
	}
	public void MakerForm() {
		f1.setTitle("도서 대여 프로그램");
		pane.setBackground(b);
		f1.setSize(1000,750);
		f1.setLocation(470,160);
		f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		pane.setLayout(null);
		
		l1 = new JLabel("책 정보를 정확히 기재해 주세요.");
		l1.setForeground(Color.WHITE);
		l1.setBounds(188, 56, 500, 30);
		l1.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l1);
		
		l2 = new JLabel("책 제목");
		l2.setForeground(Color.WHITE);
		l2.setBounds(95, 169, 100, 30);
		l2.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l2);
		
		l3 = new JLabel("저자");
		l3.setForeground(Color.WHITE);
		l3.setBounds(520, 169, 100, 30);
		l3.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l3);
		
		l4 = new JLabel("출판사");
		l4.setForeground(Color.WHITE);
		l4.setBounds(95, 255, 100, 30);
		l4.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l4);
		
		l5 = new JLabel("ISBN");
		l5.setForeground(Color.WHITE);
		l5.setBounds(520, 255, 60, 30);
		l5.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l5);
		
		l6 = new JLabel("부록");
		l6.setForeground(Color.WHITE);
		l6.setBounds(95, 331, 60, 30);
		l6.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l6);		
		
		l7 = new JLabel("장르");
		l7.setForeground(Color.WHITE);
		l7.setBounds(520, 337, 60, 30);
		l7.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l7);	
		
		l8 = new JLabel("대출여부");
		l8.setForeground(Color.WHITE);
		l8.setBounds(95, 418,100, 30);
		l8.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l8);
		
		jt1 = new JTextField();
		jt1.setBounds(197, 171, 250, 30);
		jt1.setColumns(20);
		pane.add(jt1);
		
		jt2 = new JTextField();
		jt2.setBounds(585, 171, 250, 30);
		jt2.setColumns(20);
		pane.add(jt2);
		
		jt3 = new JTextField();
		jt3.setBounds(197, 255, 250, 30);
		jt3.setColumns(20);
		pane.add(jt3);
		
		jt4 = new JTextField();
		jt4.setBounds(585, 261, 250, 30);
		jt4.setColumns(20);
		pane.add(jt4);
		
		jt5 = new JTextField();
		jt5.setBounds(197, 337, 250, 30);
		jt5.setColumns(20);
		pane.add(jt5);
		
		jt6 = new JTextField();
		jt6.setBounds(585, 337, 250, 30);
		jt6.setColumns(20);
		pane.add(jt6);
		
		jt7 = new JTextField();
		jt7.setBounds(197, 418, 250, 30);
		jt7.setColumns(20);
		pane.add(jt7);
	
		b1 = new JButton();
		b1.setIcon(new ImageIcon(BookEnter.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C4 copy copy.png")));
		b1.setBounds(737, 37, 200, 60);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);
		b1.setContentAreaFilled(false);
		b1.addActionListener(this);
		pane.add(b1);
		
		b2 = new JButton("책 등록");
		b2.setIcon(new ImageIcon(BookEnter.class.getResource("/IMAGE/\uCC45 \uB4F1\uB85D copy copy.png")));
		b2.setBounds(378, 566, 220, 50);
		b2.addActionListener(this);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);
		b2.setContentAreaFilled(false);
		pane.add(b2);
		
		b3 = new JButton("다시 쓰기");
		b3.setIcon(new ImageIcon(BookEnter.class.getResource("/IMAGE/\uB2E4\uC2DC \uC4F0\uAE30 copy copy.PNG")));
		b3.setBounds(688, 419, 136, 50);
		b3.addActionListener(this);
		b3.setBorderPainted(false);
		b3.setFocusPainted(false);
		b3.setContentAreaFilled(false);
		pane.add(b3);
		

		f1.getContentPane().add(pane);
		
		f1.setVisible(true);
	}
	
	public void DBConn() {
		try {
			Class.forName("org.mariadb.jdbc.Driver");
//			System.out.println("드라이버 적재 성공");
			con = DriverManager.getConnection("jdbc:mariadb://127.0.0.1:3306/library","root","1234");
//			System.out.println("데이터베이스 연결 성공");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("드라이버를 찾을수 없습니다");
		} catch(SQLException e){
			e.printStackTrace();
			System.out.println("데이터베이스 연결 실패");
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == b2) {
			try {
				stmt = con.createStatement();
				String SQL = "insert into books(booktitle,author,publisher,ISBN,supplement,genre,lent) values('"
			             +jt1.getText()+"','"+jt2.getText()+"','"+jt3.getText()+"','"+jt4.getText()+"','"+jt5.getText()+"','"+jt6.getText()+"','"+jt7.getText()+"')";
			stmt.executeUpdate(SQL);
			jt1.setText("");jt2.setText("");jt3.setText("");jt4.setText("");jt5.setText("");jt6.setText("");jt7.setText("");
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		}
		if(e.getSource() == b1) {
			f1.setVisible(false);
			Main.main.setVisible(true);
		}
		
		if(e.getSource() == b3) {
			jt1.setText("");jt2.setText("");jt3.setText("");jt4.setText("");jt5.setText("");jt6.setText("");
		}

	}
	
	public static void main(String[] args) {
		new BookEnter();
	}
	public void closeDatabase()
	{
		try
		{
			if( con != null )
			{
				con.close();
			}
			 
			if( stmt != null )
			{
				stmt.close();
			}
			 
			if( rs != null )
			{
				rs.close();
			}
		}
		catch (SQLException e)
		{
			System.out.println("[닫기 오류]\n" +  e.getStackTrace());
		}
	}
	
}

 

Booklist.java  // 책 목록 출력

package book;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

//판넬 색깔...

	class  JtableTestLast  extends JFrame implements ActionListener{
		String url = "jdbc:mariadb://127.0.0.1:3306/library";
		String id = "root";
		String password = "1234";
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
		int rowNum = 0, colNum = 0, tmp = 0, cnt = 0;
		
		JTextField itf;
		JButton sbutton,btnclear,hbtn;
		JScrollPane contentPane,panel2;
		JPanel panel1,panel3;
		JLabel l1,l2;
		JTable table=null;
		Color b = new Color(47,71,81);
		
		String fieldName[] ={"책제목","저자","대출 여부","장르","부록","ISBN"};
		Object data[][] = { {" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},
				{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},
				{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "},{" "," "," "," "," "," "}};
		
		public JtableTestLast(String str){
			super(str);
			try{
				Class.forName("org.mariadb.jdbc.Driver");
				con = DriverManager.getConnection(url,id,password);
				stmt = con.createStatement();
			}catch(Exception e){
				System.out.println("데이터베이스 연결 에러");
			}
			makeForm();
		}
		
		
		
		public static void main(String[] args) throws SQLException {
			new JtableTestLast("jtabletest");
	    }

		void makeForm(){
			setLocation(600,180);
			setTitle("도서 대여 프로그램");
		

			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	

			table = new JTable(data,fieldName);
			DefaultTableCellRenderer tScheduleCellRenderer = new DefaultTableCellRenderer();
			tScheduleCellRenderer.setHorizontalAlignment(SwingConstants.CENTER);
			TableColumnModel tcmSchedule = table.getColumnModel();
			for (int i = 0; i < tcmSchedule.getColumnCount(); i++) {
			tcmSchedule.getColumn(i).setCellRenderer(tScheduleCellRenderer); } //가운데 정렬
			table.setAutoCreateColumnsFromModel(true);
			 table.getTableHeader().setFont(new Font("맑은고딕", Font.BOLD, 20)); // 상단크기
			 table.getTableHeader().setBackground(new Color(86,116,109)); // 상단색
			 table.setSelectionBackground(new Color(200,200,200)); // 선택색
			 table.setRowHeight(30);//전체높이설정
			
			 
			 contentPane = new JScrollPane();
	

		    panel1 = new JPanel();
			panel1.setBackground(b);
		    panel2 = new JScrollPane(table);
		    panel3 = new JPanel();
		    panel3.setBackground(b);
		    
			 panel2.setPreferredSize(new Dimension(950,600));
		   l2 = new JLabel("이용자 주의사항  :  검색 시에는 최소 한 글자 이상 입력한 후 조회버튼을 눌러주세요.");
			l2.setFont(new Font("맑은 고딕", Font.BOLD, 20));
			l2.setForeground(Color.WHITE);
		   l1 = new JLabel("도서제목");
			l1.setFont(new Font("맑은 고딕", Font.BOLD, 20));
			l1.setForeground(Color.WHITE);
		    itf = new JTextField(20);
		 

		
		    sbutton = new JButton();
		    sbutton.setIcon(new ImageIcon(JtableTestLast.class.getResource( "/IMAGE/\uAC80\uC0C9 copy copy.png")));
		    sbutton.setBorderPainted(false);
		    sbutton.setFocusPainted(false); 
		    sbutton.setContentAreaFilled(false);
		    btnclear = new JButton();
		    btnclear.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uCD08\uAE30\uD654 copy copy.PNG")));
		    btnclear.setBorderPainted(false);
		    btnclear.setFocusPainted(false); 
		    btnclear.setContentAreaFilled(false);
		    hbtn = new JButton();
		    hbtn.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C2 copy copy.png"))); 
		    hbtn.setBorderPainted(false);
		    hbtn.setFocusPainted(false);
			hbtn.setContentAreaFilled(false);
		    

		    hbtn.addActionListener(this);
		    sbutton.addActionListener(this);
		    btnclear.addActionListener(this);
			
		    panel3.add(l2);
		    panel1.add(l1);
			panel1.add(itf);

			panel1.add(sbutton);panel1.add(btnclear);panel1.add(hbtn);
			

			add(panel1,BorderLayout.NORTH);
			add(panel2,BorderLayout.CENTER);
			add(panel3,BorderLayout.SOUTH);
			
			pack();
			setVisible(true);
		}



		@Override
		
		public void actionPerformed(ActionEvent e) {
				if(e.getSource() == sbutton){
				try {
					searchPro();
					textClear();
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
			}else if(e.getSource() == btnclear){
				textClear();
				clearPro();
			}
				if(e.getSource() == hbtn) {
					setVisible(false);
					Main.main.setVisible(true);
				}
	}
			
		private void searchPro() throws SQLException{
			rowNum = 0;		colNum = 0;
			String booktitle = itf.getText();
			String s =  "select * from books where booktitle LIKE "+"'%"+booktitle+"%';";
			rs = stmt.executeQuery(s);
	        while(rs.next()){
		        	data[rowNum][colNum] = rs.getString("booktitle");
		        	data[rowNum][colNum+1] = rs.getString("author");
		        	data[rowNum][colNum+2] = rs.getString("lent"); 	
		        	data[rowNum][colNum+3] = rs.getString("genre"); 	
		        	data[rowNum][colNum+4] = rs.getString("supplement"); 
		        	data[rowNum][colNum+5] = rs.getString("ISBN"); 
		        	rowNum = rowNum + 1;
		        };
		        formRefresh();
		}
		
		private void selectPro() throws SQLException{
			rowNum = 0;
			colNum = 0;
			String s =  "select * from books";
			rs = stmt.executeQuery(s);
	        while(rs.next()){
		        	data[rowNum][colNum] = rs.getString("booktitle");
		        	data[rowNum][colNum+1] = rs.getString("author");
		        	data[rowNum][colNum+2] = rs.getString("lent"); 	
		        	data[rowNum][colNum+3] = rs.getString("genre"); 	
		        	data[rowNum][colNum+4] = rs.getString("supplement"); 
		        	data[rowNum][colNum+5] = rs.getString("ISBN"); 
		        	rowNum = rowNum + 1;
		        };
		        formRefresh();
		}
	
	    private void formRefresh(){
	    	TableModel model = table.getModel();
	    	for(cnt = 0;cnt < rowNum; cnt++){
	    		for(tmp = 0; tmp<6;tmp++){
	    			model.setValueAt(data[cnt][tmp],cnt,tmp);
	    		}
	    	}
	    	for(cnt = rowNum; cnt < 30;cnt++){
	    		for(tmp = 0;tmp < 6;tmp++){
	    			model.setValueAt("",cnt,tmp);
	    		}
	    	}
	    }
		
		private void clearPro(){
			TableModel model = table.getModel();
			int rowNum = 30, colNum = 6;
	        for(int cnt = 0; cnt < rowNum; cnt++){
	        	for(int tmp = 0; tmp < colNum ; tmp++){
	        		model.setValueAt("", cnt, tmp);
	        	}
	        }
	        rowNum = 0; colNum = 0;    
			textClear();
		}
		
		private void textClear(){
			itf.setText("");
		}
		
		public void closeDatabase()
		{
			try
			{
				if( con != null )
				{
					con.close();
				}
				 
				if( stmt != null )
				{
					stmt.close();
				}
				 
				if( rs != null )
				{
					rs.close();
				}
			}
			catch (SQLException e)
			{
				System.out.println("[닫기 오류]\n" +  e.getStackTrace());
			}
		}

		
	}

 

Lent.java  // 대출 기능

package book;

import java.awt.Color;
import java.awt.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import java.awt.Font;
import javax.swing.ImageIcon;

public class Lent extends JFrame implements ActionListener{
	Connection con = null;
    Statement stmt = null;
    ResultSet  rs = null;
	JFrame f1 = new JFrame();
	JPanel pane = new JPanel();
	JButton b1, b2,b3,b4,b5;
	JLabel l1,l2,l3;
 JTextField jt1;
 Color b = new Color(47,71,81);
	public Lent() {
			DBConn();
			MakerForm();
			
	}
	public void MakerForm() {
		pane.setBackground(b);
		f1.setTitle("도서 대여 프로그램");
		f1.setSize(1000,750);
		f1.setLocation(470,160);
		f1.setResizable(false);
		f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		pane.setLayout(null);
		
		l1 = new JLabel("책 제목");
		l1.setForeground(new Color(255, 255, 255));
		l1.setFont(new Font("양재튼튼체B", Font.PLAIN, 25));
		l1.setBounds(261, 254, 93, 30);
		pane.add(l1);
	
		l2 = new JLabel("책 제목을 정확히 입력해주세요.");
		l2.setForeground(new Color(255, 255, 255));
		l2.setFont(new Font("양재튼튼체B", Font.PLAIN, 25));
		l2.setBounds(313, 136, 376, 30);
		pane.add(l2);
		
		
		l3 = new JLabel("대출은 회원만 가능합니다.");
		l3.setForeground(new Color(255, 255, 255));
		l3.setFont(new Font("양재튼튼체B", Font.PLAIN, 25));
		l3.setBounds(348, 652, 319, 40);
		pane.add(l3);
		
		
		jt1 = new JTextField();
		jt1.setBounds(388, 253, 331, 40);
		pane.add(jt1);
	

	
		b1 = new JButton();
		b1.setIcon(new ImageIcon(Lent.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C4 copy copy.png")));
		b1.setFont(new Font("HY나무M", Font.PLAIN, 25));
		b1.setBounds(863, 30, 117, 70);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);
		b1.setContentAreaFilled(false);
		b1.addActionListener(this);
		pane.add(b1);
		
		b2 = new JButton("");
		b2.setIcon(new ImageIcon(Lent.class.getResource("/IMAGE/\uB300\uCD9C \uBC84\uD2BC 1 copy.png")));
		b2.setForeground(new Color(0, 102, 255));
		b2.setBackground(new Color(0, 153, 153));
		b2.setFont(new Font("HY견고딕", Font.BOLD, 30));
		b2.setBounds(196, 391, 304, 80);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);
		b2.setContentAreaFilled(false);
		b2.addActionListener(this);
		pane.add(b2);
		
		b3 = new JButton("");
		b3.setIcon(new ImageIcon(Lent.class.getResource("/IMAGE/\uB300\uCD9C \uBC84\uD2BC 2 copy.png")));
		b3.setFont(new Font("HY나무M", Font.PLAIN, 25));
		b3.setBounds(505, 393, 304, 80);
		b3.setBorderPainted(false);
		b3.setFocusPainted(false);
		b3.setContentAreaFilled(false);
		b3.addActionListener(this);
		pane.add(b3);
		
		b4 = new JButton("");
		b4.setIcon(new ImageIcon(Lent.class.getResource("/IMAGE/\uB300\uCD9C \uBC84\uD2BC 3 copy.png")));
		b4.setFont(new Font("HY나무M", Font.PLAIN, 22));
		b4.setBounds(231, 494, 240, 80);
		b4.setBorderPainted(false);
		b4.setFocusPainted(false);
		b4.setContentAreaFilled(false);
		b4.addActionListener(this);
		pane.add(b4);
		
		b5 = new JButton("");
		b5.setIcon(new ImageIcon(Lent.class.getResource("/IMAGE/\uB300\uCD9C \uBC84\uD2BC 4 copy.png")));
		b5.setFont(new Font("HY나무M", Font.PLAIN, 25));
		b5.setBounds(532, 494, 240, 80);
		b5.setBorderPainted(false);
		b5.setFocusPainted(false);
		b5.setContentAreaFilled(false);
		b5.addActionListener(this);
		pane.add(b5);
		

		f1.getContentPane().add(pane);
		
		f1.setVisible(true);
	}
	
	public void DBConn() {
		try {
			Class.forName("org.mariadb.jdbc.Driver");
//			System.out.println("드라이버 적재 성공");
			con = DriverManager.getConnection("jdbc:mariadb://127.0.0.1:3306/library","root","1234");
//			System.out.println("데이터베이스 연결 성공");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("드라이버를 찾을수 없습니다");
		} catch(SQLException e){
			e.printStackTrace();
			System.out.println("데이터베이스 연결 실패");
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == b2) {
			try {
				stmt = con.createStatement();
				String SQL = "UPDATE books SET lent='대출불가능'"+"WHERE booktitle='"+jt1.getText()+"';";
			stmt.executeUpdate(SQL);
			jt1.setText("");
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		}
		if(e.getSource() == b1) {
			f1.setVisible(false);
			Main.main.setVisible(true);
		}

		if(e.getSource() == b3) {
			try {
				stmt = con.createStatement();
				String SQL = "UPDATE books SET lent='대출가능'"+"WHERE booktitle='"+jt1.getText()+"'";
			stmt.executeUpdate(SQL);
			jt1.setText("");
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		}
		
		if(e.getSource() == b4) {
			f1.setVisible(false);
			JtableTestLast JTableTestLast = new JtableTestLast("jtabletest");
		}
		
		if(e.getSource() == b5) {
			f1.setVisible(false);
			Member f1 = new Member();
		}
		
	}
	
	public static void main(String[] args) {
		new Lent();
	}
	public void closeDatabase()
	{
		try
		{
			if( con != null )
			{
				con.close();
			}
			 
			if( stmt != null )
			{
				stmt.close();
			}
			 
			if( rs != null )
			{
				rs.close();
			}
		}
		catch (SQLException e)
		{
			System.out.println("[닫기 오류]\n" +  e.getStackTrace());
		}
	}
}

 

 

Main.java  //메인 화면

package book;


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.sql.SQLException;

import javax.swing.*;



public class Main extends JFrame implements ActionListener {
	
	static JFrame main;
	static JPanel p1;
	static JLabel l1,label2;
	static JButton b1,b2, b3, b4, b5,b6;
	
	
	
	Color b = new Color(47,71,81);

	
	public Main() {

		main = new JFrame();
		main.setTitle("도서 대여 프로그램");
		main.setSize(1000,750);
		main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		main.setResizable(false);
		main.setLocation(600,200);
		JPanel();
		main.setVisible(true);
		
	}
	public void JPanel() {
	
		
		p1 = new JPanel();
		p1.setLayout(null);
		p1.setBackground(b);
		p1.setLocation(600,200);
		
		
		
		b1 = new JButton(new ImageIcon(Main.class.getResource("/IMAGE/\uBC84\uD2BC 1 copy copy.jpg")));
		b1.setBounds(14,265, 364, 200);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);
		b1.setContentAreaFilled(false);
		b1.addActionListener(this);
		p1.add(b1);
		
		b2 = new JButton("");
		b2.setIcon(new ImageIcon(Main.class.getResource("/IMAGE/\uBC84\uD2BC 2 copy copy.jpg")));
		b2.setBounds(336, 265, 336, 200);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);
		b2.setContentAreaFilled(false);
		b2.addActionListener(this);
		p1.add(b2);
		
		b5 = new JButton("");
		b5.setIcon(new ImageIcon(Main.class.getResource("/IMAGE/\uBC84\uD2BC 3 copy copy.jpg")));
		b5.setBounds(649, 265, 317, 200);
		b5.setBorderPainted(false);
		b5.setFocusPainted(false);
		b5.setContentAreaFilled(false);
		b5.addActionListener(this);
		p1.add(b5);
		
		b4 = new JButton("");
		b4.setIcon(new ImageIcon(Main.class.getResource("/IMAGE/\uBC84\uD2BC 4 copy copy.jpg")));
		b4.setBounds(34,465, 324, 200);
		b4.setBorderPainted(false);
		b4.setFocusPainted(false);
		b4.setContentAreaFilled(false);
		b4.addActionListener(this);
		p1.add(b4);
		
		b3 = new JButton("");
		b3.setIcon(new ImageIcon("C:\\Users\\\uBBFC\uC601\\Desktop\\\uB3C4\uC11C\uAD00 \uD3EC\uD1A0\uC0F5 \uC218\uC815\uC218\uC815\\\uBC84\uD2BC 5 copy copy.jpg"));
		b3.setBounds(336, 465, 336, 200);
		b3.setBorderPainted(false);
		b3.setFocusPainted(false);
		b3.setContentAreaFilled(false);
		b3.addActionListener(this);
		p1.add(b3);
		
		main.getContentPane().add(p1);
		
		b6 = new JButton();
		b6.setIcon(new ImageIcon(Main.class.getResource("/IMAGE/\uB2E4\uC6B4\uB85C\uB4DC (1).jpg")));
		b6.setBounds(659, 465, 303, 200);
		b6.setBorderPainted(false);
		b6.setFocusPainted(false);
		b6.setContentAreaFilled(false);
		b6.addActionListener(this);
		p1.add(b6);
		
		JLabel label2 = new JLabel("도서 대여 프로그램");
		label2.setFont(new Font("양재튼튼체B", Font.PLAIN, 50));
		label2.setForeground(Color.WHITE);
		label2.setBounds(34, 57, 567, 165);
		p1.add(label2);
		
	}
	public static void main(String[] args) {
		new Main();
	}
		
	@Override
	public void actionPerformed(ActionEvent e) {
			if(e.getSource() == b1) {
				main.setVisible(false);
				JtableTestLast JTableTestLast = new JtableTestLast("jtabletest");
			}
			if(e.getSource() == b2) {
				main.setVisible(false);
				Lent lent = new Lent();
			}
			if(e.getSource() == b3) {
				main.setVisible(false);
				Managerment manage = new Managerment("Managerment");
			}
			if(e.getSource() == b4) {
				main.setVisible(false);
				Member f1 = new Member();
			}
			if(e.getSource() == b5) {
				main.setVisible(false);
				BookEnter be = new BookEnter();
			}
			if(e.getSource() == b6) {
				main.setVisible(false);
				BookDel bd = new BookDel();
			}
		}
	}

 

 

Management.java  //회원 목록 출력

package book;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

	class  Managerment  extends JFrame implements ActionListener{
		String url = "jdbc:mariadb://127.0.0.1:3306/library";
		String id = "root";
		String password = "1234";
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
		int rowNum = 0, colNum = 0, tmp = 0, cnt = 0;
		
		JTextField itf;
		JButton sbutton,btnclear,hbtn,delbtn;
		JScrollPane contentPane,panel2;
		JPanel panel1,panel3;
		JLabel l1,l2;
		JTable table=null;
		Color b = new Color(47,71,81);
	
		
		String fieldName[] ={"이름","생년월일","연락처","이메일","성별"};
		Object data[][] = { {" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},
				{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},
				{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "},{" "," "," "," "," "}};
		
		public Managerment(String str){
			super(str);
			try{
				Class.forName("org.mariadb.jdbc.Driver");
				con = DriverManager.getConnection(url,id,password);
				stmt = con.createStatement();
			}catch(Exception e){
				System.out.println("데이터베이스 연결 에러");
			}
			makeForm();
		}
		
		public static void main(String[] args) throws SQLException {
			new Managerment("Managerment");
	    }

		void makeForm(){
			setTitle("도서 대여 프로그램");
			setLocation(470,160);
			setResizable(false);
			
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
		 	
			table = new JTable(data,fieldName);
			DefaultTableCellRenderer tScheduleCellRenderer = new DefaultTableCellRenderer();
			tScheduleCellRenderer.setHorizontalAlignment(SwingConstants.CENTER);
			TableColumnModel tcmSchedule = table.getColumnModel();
			for (int i = 0; i < tcmSchedule.getColumnCount(); i++) {
			tcmSchedule.getColumn(i).setCellRenderer(tScheduleCellRenderer); } //가운데 정렬
			table.setAutoCreateColumnsFromModel(true);
			 table.getTableHeader().setFont(new Font("맑은고딕", Font.BOLD, 20)); // 상단크기
			 table.getTableHeader().setBackground(new Color(86,116,109)); // 상단색
			 table.setSelectionBackground(new Color(200,200,200)); // 선택색
			 table.setRowHeight(30);//전체높이설정
			
			
			contentPane = new JScrollPane();
			
			 panel1 = new JPanel();
				panel1.setBackground(b);
			    panel2 = new JScrollPane(table);
			    panel3 = new JPanel();
			    panel3.setBackground(b);
			    
		    panel2.setPreferredSize(new Dimension(950,600));
		   l2 = new JLabel("이용자 주의사항  :  반드시 최소 한 글자 입력 후 조회버튼을 눌러주세요.");
			l2.setFont(new Font("맑은 고딕", Font.BOLD, 20));
			l2.setForeground(Color.WHITE);
		   l1 = new JLabel("회원 이름");
			l1.setFont(new Font("맑은 고딕", Font.BOLD, 20));
			l1.setForeground(Color.WHITE);
		    itf = new JTextField(20);
		 

		    
		    sbutton = new JButton();
		    sbutton.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uC870\uD68C copy copy.PNG")));
		    sbutton.setBorderPainted(false);
		    sbutton.setFocusPainted(false);
		    sbutton.setContentAreaFilled(false);
		    btnclear = new JButton();
		    btnclear.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uCD08\uAE30\uD654 copy copy.PNG")));
		    btnclear.setBorderPainted(false);
		    btnclear.setFocusPainted(false);
		    btnclear.setContentAreaFilled(false);
		    delbtn = new JButton();
		    delbtn.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uD0C8\uD1F4 copy copy.png")));
		    delbtn.setBorderPainted(false);
		    delbtn.setFocusPainted(false);
		    delbtn.setContentAreaFilled(false);
		    hbtn = new JButton();
		    hbtn.setIcon(new ImageIcon(JtableTestLast.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C2 copy copy.png")));
		    hbtn.setBorderPainted(false);
		    hbtn.setFocusPainted(false);
			hbtn.setContentAreaFilled(false);
		

		    hbtn.addActionListener(this);
		    sbutton.addActionListener(this);
		    btnclear.addActionListener(this);
		    delbtn.addActionListener(this);
		    
		    panel3.add(l2);
		    panel1.add(l1);
			panel1.add(itf);

			panel1.add(sbutton);panel1.add(btnclear);panel1.add(delbtn);panel1.add(hbtn);
			

			add(panel1,BorderLayout.NORTH);
			add(panel2,BorderLayout.CENTER);
			add(panel3,BorderLayout.SOUTH);
			
			pack();
			setVisible(true);
		}

		@Override
		
		public void actionPerformed(ActionEvent e) {
				if(e.getSource() == sbutton){
				try {
					searchPro();
					textClear();
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
			}else if(e.getSource() == btnclear){
				textClear();
				clearPro();
			}
				if(e.getSource() == hbtn) {
					setVisible(false);
					Main.main.setVisible(true);
				}
				
				if(e.getSource() == delbtn) {
					try {
						delete();
						textClear();
					} catch (SQLException e1) {
						e1.printStackTrace();
					}
				}
	}
			
		private void searchPro() throws SQLException{
			rowNum = 0;		colNum = 0;
			String name = itf.getText();
			String s =  "select * from member where name LIKE "+"'%"+name+"%';";
			rs = stmt.executeQuery(s);
	        while(rs.next()){
		        	data[rowNum][colNum] = rs.getString("name");
		        	data[rowNum][colNum+1] = rs.getString("birth");
		        	data[rowNum][colNum+2] = rs.getString("phonenumber"); 
		        	data[rowNum][colNum+3] = rs.getString("email"); 	
		        	data[rowNum][colNum+4] = rs.getString("gender"); 	
		        	rowNum = rowNum + 1;
		        };
		        formRefresh();
		}
		
		private void selectPro() throws SQLException{
			rowNum = 0;
			colNum = 0;
			String s =  "select * from member;";
			rs = stmt.executeQuery(s);
	        while(rs.next()){
	        	data[rowNum][colNum] = rs.getString("name");
	        	data[rowNum][colNum+1] = rs.getString("birth");
	        	data[rowNum][colNum+2] = rs.getString("phonenumber"); 
	        	data[rowNum][colNum+3] = rs.getString("email"); 	
	        	data[rowNum][colNum+4] = rs.getString("gender"); 	
		        	rowNum = rowNum + 1;
		        };
		        formRefresh();
		}
	
	    private void formRefresh(){
	    	TableModel model = table.getModel();
	    	for(cnt = 0;cnt < rowNum; cnt++){
	    		for(tmp = 0; tmp<5;tmp++){
	    			model.setValueAt(data[cnt][tmp],cnt,tmp);
	    		}
	    	}
	    	for(cnt = rowNum; cnt < 30;cnt++){
	    		for(tmp = 0;tmp < 5;tmp++){
	    			model.setValueAt("",cnt,tmp);
	    		}
	    	}
	    }
		
		private void clearPro(){
			TableModel model = table.getModel();
			int rowNum = 30, colNum = 5;
	        for(int cnt = 0; cnt < rowNum; cnt++){
	        	for(int tmp = 0; tmp < colNum ; tmp++){
	        		model.setValueAt("", cnt, tmp);
	        	}
	        }
	        rowNum = 0; colNum = 0;    
			textClear();
		}
		
		private void textClear(){
			itf.setText("");
		}
		
		private void delete() throws SQLException{
			rowNum = 0;		colNum = 0;
			String name = itf.getText();
			String s =  "delete from member where name = "+"'"+name+"';";
			rs = stmt.executeQuery(s);
	        while(rs.next()){
		        	data[rowNum][colNum] = rs.getString("name");
		        	data[rowNum][colNum+1] = rs.getString("birth");
		        	data[rowNum][colNum+2] = rs.getString("phonenumber"); 
		        	data[rowNum][colNum+3] = rs.getString("email"); 	
		        	data[rowNum][colNum+4] = rs.getString("gender"); 	
		        	rowNum = rowNum + 1;
		        };
		        formRefresh();
		}
		
		public void closeDatabase()
		{
			try
			{
				if( con != null )
				{
					con.close();
				}
				 
				if( stmt != null )
				{
					stmt.close();
				}
				 
				if( rs != null )
				{
					rs.close();
				}
			}
			catch (SQLException e)
			{
				System.out.println("[닫기 오류]\n" +  e.getStackTrace());
			}
		}

		
	}

 

Member.java  //회원 등록

package book;
import java.awt.Color;
import java.awt.Font;
import java.awt.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ImageIcon;

public class Member extends JFrame implements ActionListener{
	Connection con = null;
    Statement stmt = null;
    ResultSet  rs = null;
	JFrame f1 = new JFrame();
	JPanel pane = new JPanel();
	JButton b1, b2,b3;
	JLabel l1,l2,l3,l4,l5,l6;
 JTextField jt1, jt2,jt3, jt4, jt5;
	Color b = new Color(47,71,81);
	
	public Member() {
			DBConn();
			MakerForm();
			
	}
	public void MakerForm() {
		f1.setTitle("도서 대여 프로그램");
		pane.setBackground(b);
		f1.setSize(1000,750);
		f1.setLocation(470,160);
		f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		pane.setLayout(null);
		
		l1 = new JLabel("개인 정보를 정확히 기재해 주세요.");
		l1.setForeground(Color.WHITE);
		l1.setBounds(180, 40, 500, 30);
		l1.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l1);
		l2 = new JLabel("이름");
		l2.setForeground(Color.WHITE);
		l2.setBounds(225, 126, 50, 30);
		l2.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l2);
		l3 = new JLabel("생년월일");
		l3.setForeground(Color.WHITE);
		l3.setBounds(225, 202, 100, 30);
		l3.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l3);
		l4 = new JLabel("전화번호");
		l4.setForeground(Color.WHITE);
		l4.setBounds(225, 291, 100, 30);
		l4.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l4);
		l5 = new JLabel("e-Mail");
		l5.setForeground(Color.WHITE);
		l5.setBounds(225, 381, 86, 30);
		l5.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l5);
		l6 = new JLabel("성별");
		l6.setForeground(Color.WHITE);
		l6.setBounds(225, 477, 60, 30);
		l6.setFont(new Font("맑은 고딕", Font.BOLD, 25));
		pane.add(l6);		
		
		jt1 = new JTextField();
		jt1.setBounds(350, 132, 250, 30);
		jt1.setColumns(20);
		pane.add(jt1);
		jt2 = new JTextField();
		jt2.setBounds(350, 208, 250, 30);
		jt2.setColumns(20);
		pane.add(jt2);
		jt3 = new JTextField();
		jt3.setBounds(350, 297, 250, 30);
		jt3.setColumns(20);
		pane.add(jt3);
		jt4 = new JTextField();
		jt4.setBounds(350, 387, 250, 30);
		jt4.setColumns(20);
		pane.add(jt4);
		jt5 = new JTextField();
		jt5.setBounds(350, 483, 250, 30);
		jt5.setColumns(20);
		pane.add(jt5);
	
		b1 = new JButton();
		b1.setIcon(new ImageIcon(Member.class.getResource("/IMAGE/\uBA54\uC778\uD654\uBA74\uC73C\uB85C4 copy copy.png")));
		b1.setBounds(748, 31, 200, 60);
		b1.addActionListener(this);
		b1.setBorderPainted(false);
		b1.setFocusPainted(false);
		b1.setContentAreaFilled(false);
		pane.add(b1);
		
		b2 = new JButton("가입");
		b2.setIcon(new ImageIcon(Member.class.getResource("/IMAGE/\uAC00\uC785 copy copy.png")));
		b2.setBounds(402, 599, 185, 50);
		b2.addActionListener(this);
		b2.setBorderPainted(false);
		b2.setFocusPainted(false);
		b2.setContentAreaFilled(false);
		pane.add(b2);
		
		b3 = new JButton("다시 쓰기");
		b3.setIcon(new ImageIcon(Member.class.getResource("/IMAGE/\uB2E4\uC2DC \uC4F0\uAE302 copy copy.png")));
		b3.setBounds(684, 305, 137, 40);
		b3.addActionListener(this);
		b3.setBorderPainted(false);
		b3.setFocusPainted(false);
		b3.setContentAreaFilled(false);
		pane.add(b3);
		

		f1.getContentPane().add(pane);
		
		f1.setVisible(true);
	}
	
	public void DBConn() {
		try {
			Class.forName("org.mariadb.jdbc.Driver");
//			System.out.println("드라이버 적재 성공");
			con = DriverManager.getConnection("jdbc:mariadb://127.0.0.1:3306/library","root","1234");
//			System.out.println("데이터베이스 연결 성공");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("드라이버를 찾을수 없습니다");
		} catch(SQLException e){
			e.printStackTrace();
			System.out.println("데이터베이스 연결 실패");
		}
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == b2) {
			try {
				stmt = con.createStatement();
				String SQL = "insert into member(name,birth,phonenumber,email,gender) values('"
			             +jt1.getText()+"','"+jt2.getText()+"','"+jt3.getText()+"','"+jt4.getText()+"','"+jt5.getText()+"')";
			stmt.executeUpdate(SQL);
			jt1.setText("");jt2.setText("");jt3.setText("");jt4.setText("");jt5.setText("");
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		}
		if(e.getSource() == b1) {
			f1.setVisible(false);
			Main.main.setVisible(true);
		}
		
		if(e.getSource() == b3) {
			jt1.setText("");jt2.setText("");jt3.setText("");jt4.setText("");jt5.setText("");
		}

	}
	
	public static void main(String[] args) {
		new Member();
	}
	public void closeDatabase()
	{
		try
		{
			if( con != null )
			{
				con.close();
			}
			 
			if( stmt != null )
			{
				stmt.close();
			}
			 
			if( rs != null )
			{
				rs.close();
			}
		}
		catch (SQLException e)
		{
			System.out.println("[닫기 오류]\n" +  e.getStackTrace());
		}
	}
	
}