Os exemplos deste artigo compartilham o código específico do gerenciamento de livros de estudantes da Java GUI para sua referência. O conteúdo específico é o seguinte
- Construção de tabela de banco de dados MySQL:
1.Book tabela
2.Bs Formulário de registro de empréstimo do livro
3.STD Tabela de alunos
4.DL Tabela de usuário de login
.
- Liste o conteúdo
1.databd.java // Portal do programa e verificação de login
importar java.awt.*; importar java.awt.event.*; importar java.sql. String getUser = ""; String getpd = ""; String sql = "Selecione * de dl onde id = '"; String sql1 = "Selecione senha em dl onde senha = '"; JButton btnnewButton = new JButton ("Login"); Jbutton btnnewbutton_1 = new jbutton ("registro"); JTextfield show = novo JTextfield ("/t, selecione o botão", 10); PRIVADO JPALEL CONTENTPANE; Private JTextField Userfield; Private JPasswordField Pwdfield; Declaração privada Declaração = NULL; // Consulta de declaração privada da conta privada2 = null; // REGISTRA CONTA DE DATATA DE ESTÁTICO PRIVADO DE DATATIVA DE ESTÁTICA; // ResultSet rst2 = null; public static void main (string [] args) {eventQueue.invokelater (new runnable () {public void run () {try {frame = new Databd (); frame.setVisible (true);} catch (exceção e) {e.printStackTrace ();}}}); } public databd () {string driver = "com.mysql.jdbc.driver"; String url = "jdbc: mysql: // localhost: 8088/biblioteca? UseUnicode = true & caracterEncoding = utf-8 & usessl = false"; String user = "root"; String senha = "11111"; tente {class.ForName (driver); Conexão conn = driverManager.getConnection (URL, usuário, senha); Conexão conn2 = driverManager.getConnection (URL, usuário, senha); declaração = conn.createstatement (); declaração2 = Conn2.Createstatement (ResultSet.type_scroll_sensitive, ResultSet.Concur_UpDatable); rst2 = declaração2.ExecuteQuery ("Selecione * de DL"); show.seteditable (false); setDefaultCloseoperation (jframe.exit_on_close); Setsize (250, 200); setLocationRelativeTo (NULL); contentPane = new JPanel (); contentPane.setborder (New Emptyborder (5, 5, 5, 5)); contentPane.setLayout (NULL); add (contentPane); Jlabel lbloUsername = new jlabel ("conta"); lbloUsername.setbounds (12, 13, 54, 15); contentPane.add (lblovername); Jlabel lblpassword = new jlabel ("senha"); lblPassword.setbounds (12, 38, 54, 15); contentPane.add (lblPassword); Userfield = new JTextField (); Userfield.setBounds (76, 10, 144, 21); contentPane.add (usuário do usuário); userfield.setColumns (10); pwdfield = new jpasswordfield (); pwdfield.setechar ('*'); // Senha eco dos caracteres pwdfield.setbounds (76, 35, 144, 21); contentPane.add (PWDField); pwdfield.setColumns (10); add (show, borderlayout.south); btnnewbutton.addactionListener (isto); // Login btnnewbutton.setbounds (10, 92, 93, 23); contentpane.add (BtnnewButton); btnnewbutton_1.addactionListener (this); // Registre btnnewbutton_1.setbounds (127, 92, 93, 23); contentPane.add (btnnewbutton_1); show.addactionListener (isto); } catch (classNotFoundException e) {System.out.print ("Drive não encontrado"); } Catch (Exceção e) {System.out.print ("Ocorreu o erro"); E.PrintStackTrace ();}} public void ActionPerformed (ActionEvent e) {getUser = userfield.getText (). TRIM ()+"'"; String pd = string.valueof (pwdfield.getpassword ()); tente {ResultSet rs = declaration.executeQuery (SQL+getUser); if (e.getSource () == btnnewButton) {// Login if (rs.next ()) {if (rs.getString (2) .equals (pd)) {frame.setvisible (false); JoptionPane.showMessagedialog (null, "Login com sucesso"); Uimanager.setLookAndFeel (uimanager.getSystemLookAndFeelClassName ()); a = Framedemo.a; // gera um objeto estático} else Show.settext ("/t Erro de senha"); } else show.settext ("/t Conta não existe"); } else if (e.getSource () == btnnewbutton_1) {// Registre if (userfield.getText (). Equals ("")) {show.settext ("/t registrado conta não pode ser vazio");} else {if (string.valueof (pwdfield.xtPass. vazio"); else {register ();}}}}} catch (Exceção c) {c.printStackTrace ();}} private void registr () {string name = userfield.getText (), passwd = string.valueof (pwdfield.getpassword ()); tente {rst2.movetoinsertrow (); rst2.UpDateString (1, nome); rst2.UpDateString (2, Passwd); rst2.insertrow (); rst2.Movetocurrentrow (); show.settext ("/t registro com sucesso"); } catch (Exceção e) {show.settext ("/t registro falhou");}}}2.FameDemo // Principal Framework, entregue o evento à classe de addinformation
package database;import javax.swing.*;import javax.swing.border.TitledBorder;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.Calendar;import java.util.GregorianCalendar;public class frameDemo extends JFrame implements ActionListener{ public static Framedemo A = new Framedemo (); JPanel Painel = new JPanel (), Painel1 = new JPanel (), Painel2 = New JPanel (), Painel3 = New JPanel (), Painel4 = New JPanel (), Painel5 = New Jpanel (); String [] Adds = {"Selecione a operação", "Adicionar registro de coleção", "Adicionar registro de empréstimo de livro", "Adicionar registro do aluno"}; String [] delete = {"Selecione a operação", "Excluir registro de coleta", "Excluir registro de empréstimo de livro", "Excluir registro do aluno"}; String [] alterações = {"Selecione a operação", "Modifique o registro do inventário", "Data to Return"}; String [] Querys = {"Selecione a operação", "Número do livro de consulta", "Consulta Student Empréstimo Record", "Consulta Informações do aluno"}; String [] mostra = {"Selecione a operação", "Show todos os registros de coleção", "Mostrar registros de empréstimos", "Show Student Records"}; String [] registro = new String [4]; Jtextarea ta = new jtextarea ("-> bem-vindo ao uso do sistema/n", 11,60); JScrollPane painel = novo JScrollPane (TA); Conexão conn = null; Instrução stmt = null; Instrução stmt1 = null; Instrução stmt2 = null; ResultSet RST = NULL; ResultSet RST1 = NULL; ResultSet RST2 = NULL; chave booleana estática; privado jframe big = new jframe ("Selecione a operação"); Private JComBobox add = new JCOMBOBOX (Adds); private JCOMBOBOX DELETE = novo JCOMBOBOX (delete); private JCOMBOBox Change = novo JCOMBOBOX (mudanças); consulta privada jcombobox = novo JCOMBOBOX (consultas); Mostra privado JCOMBOBOX = novo JCOMBOBOX (mostra); public Framedemo () {Super ("Sistema de Gerenciamento da Biblioteca"); tente {Class.ForName ("com.mysql.jdbc.driver"); String url = "jdbc: mysql: // localhost: 8088/biblioteca? UseUnicode = true & caracterEncoding = utf-8 & usessl = false"; String user = "root"; String senha = "111111"; Conn = DriverManager.getConnection (URL, usuário, senha); Panel4.SetLayout (New GridLayout (3,1,30,10)); Panel4.Setborder (novo TitledBerder ("Select Management:")); painel1.add (New Jlabel ("Adicione registro:")); painel1.add (add); painel1.add (New Jlabel ("Excluir registro:")); painel1.add (delete); painel2.add (New Jlabel ("Modify Record:")); painel2.add (alteração); painel2.add (New Jlabel ("Registro de consulta:")); painel2.add (consulta); painel3.Add (New Jlabel ("SHOW); Panel4.Add (Panel1); Panel4.Add (Panel2); Panel4.add (Painel3); Panel5.add (Pane); Painel.add (Panel5, BorderLayout.South); Painel.Add (Painel4, BorderLayout.Center); (Painel); stmt = conn.createstatement (ResultSet.type_scroll_sensitive, ResultSet.Concur_UpDatable); STMT2 = CONNECIMENTO DO CONSIMADOR (Resultado do Resultado. // setResizable (false); if (add.getSelectedIndEx () == 1) {Ta.append ("-> Adicionar registro de coleta/n"); Número "," Número do aluno ", 2);} else if (add.getSelectedIndex () == 3) {Ta.append ("-> Adicione Student Record/N "); addinformation A1 = new Addinformation (" ALUGO Número do aluno, "Nome do aluno", 3);} Add.SetSELECTEM ("Por favor, número 1); Ta.Append ("Excluir registro de coleta/n"); Delete.getSelectIndEx () == 3) {Ta.append ("-> Exclua o registro do aluno/n"); A1 = novo addinformation ("Número do livro", "Número de inventário", 7); if (query.getSelectedIndex () == 1) {Ta.append ("-> consulta por título do livro/n"); } else if (query.getSelectIndEx () == 3) {Ta.append ("-> Consulta Aluno empréstimos Records/N"); número ", 12);} query.setSelectedItem (" Selecione a operação "); if (show.getSelectedIndex () == 1) {ta.append ("-> show todos os registros de coleção/n "); tente {rst = stmt.executeQuery (" selecione * de livro "); rst.first (); ta.append("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- TAPEND (T "/T"/T "/T"/T "+NUM" Execução, o cursor aponta para a última posição da última linha, rst.first (); TA.APPEND ("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- rst1 = stmt1.executeQuery ("selecione * de BS"); ta.append("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ utildate = (java.util.date) calendário.gettime (); Ta.Append ("T"+BookId+"/T"+Stdid+" calendário.add (calendário.date, 30); ta.append ("/t"+bookId+"/t"+stdid+"/t"+x+"/t"+newDate+"/n"); Ta.append ("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nome = rst2.getString (2); ta.append ("/t"+id+"/t"+nome+"/t"+"/n"); TA.APPEND ("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ta.setCaretPosition (Ta.getText (). Length ()); TA.APPEND ("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ta.Append (Id+"Nome+" "Brand+" "Preço+" "+marca+" "+preço+" "+estoque+"/n ");} // Após a execução, o cursor aponta para a última posição da última linha rst.absolute (a); Ta.append ("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------3.Addinformation.java // lidera eventos
banco de dados do pacote; importar javax.swing.*; importar java.util.calendar; importar java.util.gregiancalendar; importar java.awt.*; importar java.awt.event.*; import java.sql.* quxiao = novo jbutton ("cancel"); JTextfield jtf1 = new JTextfield (10), jtf2 = new jtextfield (10), jtf3 = new jtextfield (10); Conexão conn = null; static {try {class.formoname ("com.mysql.jdbc.driver"); } catch (Exceção e) {e.printStackTrace ();}} int x = 0; Public Connection getConnection () lança SQLException {if (Conn == null) {Conn = DriverManager.getConnection ("JDBC: mysql: // localhost: 8088/biblioteca? useunicode = true & caracterEncoding = utf-8 & usessl = false", "root", "1111111111111111111111111111111111111) } retornar Conn; } addinformation (string s1, string s2, string s3, int m) {jpanel p = new jpanel (); p.setLayout (new FlowLayout ()); P.Add (New Jlabel (S1)); P.Add (JTF1); P.Add (New Jlabel (S2)); P.Add (JTF2); P.Add (New Jlabel (S3)); P.Add (JTF3); p.add (claro); P.Add (Quxiao); add (p); if (m == 8) {JoptionPane.ShowMessAgedialog (null, "a data do livro deve estar no formato xxxx-xx-xx!", "Warning", joptionpane.warning_message); } SetSize (500, 100); setvisible (true); setDefaultCloseoperation (jframe.dispose_on_close); setLocationRelativeTo (NULL); CEURO.AddactionListener (isto); quxiao.addactionListener (isto); x = m; } addinformation (string s1, string s2, int m) {jpanel p = new jpanel (); p.setLayout (new FlowLayout ()); P.Add (New Jlabel (S1)); P.Add (JTF1); P.Add (New Jlabel (S2)); P.Add (JTF2); p.add (claro); P.Add (Quxiao); add (quxiao); add (p); SetSize (500, 100); setvisible (true); setDefaultCloseoperation (jframe.dispose_on_close); setLocationRelativeTo (NULL); CEURO.AddactionListener (isto); quxiao.addactionListener (isto); x = m; } addinformation (string s1, int m) {jpanel p = new jpanel (); p.setLayout (new FlowLayout ()); P.Add (New Jlabel (S1)); P.Add (JTF1); if (m == 4) {JoptionPane.ShowMessagedialog (nulo, "Se houver um registro de empréstimo, as informações do livro não podem ser excluídas!", "Aviso", JoptionPane.warning_message); } if (m == 6) {JoptionPane.showMessagedialog (NULL, "Se houver um registro de empréstimo, as informações do aluno não podem ser excluídas!", "Aviso", JoptionPane.warning_message); } p.add (claro); P.Add (Quxiao); add (p); SetSize (500, 80); setvisible (true); setDefaultCloseoperation (jframe.dispose_on_close); setLocationRelativeTo (NULL); CEURO.AddactionListener (isto); quxiao.addactionListener (isto); x = m; } public void ActionPerformed (ActionEvent Ae) {if (ae.getSource () == Claro) {if (x == 1) {// Adicione a coleção String string sql = "inserir nos valores dos livros (? ,? ,?)"; tente (conexão conn = getConnection (); preparadostatement stmt = conn.preparestatement (sql)) {int id = integer.parseint (jtf1.getText ()); Nome da sequência = JTF2.getText (); int num = Integer.parseint (jtf3.getText ()); stmt.setInt (1, id); stmt.SetString (2, nome); stmt.setInt (3, num); stmt.executeUpdate (); Framedemo.a.ta.append ("-> Adicionar sucesso/n"); } Catch (Exceção x) {Famedemo.a.ta.append ("-> inserir erro/n"); x.printStackTrace ();} addinformation.This.Dispose (); } if (x == 2) {// Adicione um registro de empréstimo string sql = "inserir em bs (bookId, stdid, data) valores (?,?)"; String sql1 = "Selecione ID, num do livro onde id =?"; String sql2 = "Selecione ID de std where id =?"; tente {conexão conn1 = getConnection (); Preparado STMT1 = Conn1.Preparestatement (SQL1, ResultSet.type_scroll_sensitive, ResultSet.Concur_UpDatable); stmt1.setInt (1, Integer.parseint (jtf1.getText ())); ResultSet rst1 = stmt1.executeQuery (); // Veja se existe este livro e se o inventário é 0 se (rst1.next () && (rst1.getInt (2)> 0)) {int n = rst1.getInt (2); n- = 1; int m = rst1.getInt (1); rst1.Updateint (1, m); rst1.Updateint (2, n); rst1.updaterow (); Conexão conn2 = getConnection (); Preparado STMT2 = Conn2.Preparestatement (SQL2); stmt2.SetInt (1, Integer.Parseint (JTF2.getText ())); ResultSet rst2 = stmt2.ExecuteQuery (); // alguém se (rst2.Next ()) {conexão conn = getConnection (); Preparado STMTENT STMT = Conn.Preparestatement (SQL); int bookId = Integer.parseint (jtf1.getText ()); int stdid = Integer.parseint (jtf2.getText ()); stmt.setInt (1, bookid); stmt.setInt (2, stdid); stmt.setDate (3, New Date (System.CurrentTimemillis ())); stmt.executeUpdate (); Framedemo.a.ta.append ("-> Adicionar sucesso/n"); } else {Framedemo.a.ta.append ("-> sem registro de estudante, nenhum registro de empréstimo/n");}} else {Framedemo.a.ta.append ("-> não Este livro ou foi emprestado tudo/n");}}} (exceção x) {FameDemo.a.ta.ta.Apn (n ");}}} (Exceção x) {FameDemo.a.ta.ta.tan. x.printStackTrace ();} addinformation.This.Dispose (); } if (x == 3) {// Adicione o registro do aluno string sql = "inserir em valores de std (?,?)"; tente (conexão conn = getConnection (); preparadostatement stmt = conn.preparestatement (sql)) {int id = integer.parseint (jtf1.getText ()); Nome da sequência = JTF2.getText (); stmt.setInt (1, id); stmt.SetString (2, nome); stmt.executeUpdate (); Framedemo.a.ta.append ("-> Adicionar sucesso/n"); } Catch (Exceção x) {Famedemo.a.ta.append ("-> inserir erro/n"); x.printStackTrace ();} addinformation.This.Dispose (); } if (x == 4) {// exclua o livro String string sql = "exclua do livro onde id =?"; String sql1 = "Selecione * de BS onde bookId =?"; tente {conexão conn1 = getConnection (); Preparado STMT1 = Conn1.Preparestatement (SQL1); stmt1.setInt (1, Integer.parseint (jtf1.getText ())); ResultSet RST1 = STMT1.EXECUTEQUERY (); if (rst1.Next ()) {// Há um livro no registro de empréstimo, JoptionPane.showMessagedialog (null, "Há um registro de empréstimo para o livro no registro de empréstimos!", "Aviso", JoptionPane.warning_message); } else {// não há livro no registro de empréstimo, conexão conn = getConnection (); Preparado STMTENT STMT = Conn.Preparestatement (SQL); int id = intege.parseint (jtf1.getText ()); stmt.setInt (1, id); int t = stmt.executeUpdate (); if (t == 0) {Famedemo.a.ta.append ("-> excluir erro/n"); JoptionPane.ShowMessagedialog (Null, "As informações do livro não existem!", "Aviso", JoptionPane.warning_message); } else Framedemo.a.ta.append ("-> Excluir registro com sucesso/n"); }} Catch (Exceção x) {Famedemo.a.ta.append ("-> exclusão falhada/n"); x.printStackTrace ();} addinformation.this.dispose (); } if (x == 5) {// exclua o livro Record String string sql = "Exclua do BS onde bookId =? e stdid =?"; String sql1 = "Selecione ID, num do livro onde id =?"; tente {conexão conn = getConnection (); Preparado STMTENT STMT = Conn.Preparestatement (SQL); int bookId = Integer.parseint (jtf1.getText ()); int stdid = Integer.parseint (jtf2.getText ()); stmt.setInt (1, bookid); stmt.setInt (2, stdid); int t = stmt.executeUpdate (); if (t! = 0) {conexão conn1 = getConnection (); Preparado STMT1 = Conn1.Preparestatement (SQL1, ResultSet.type_scroll_sensitive, ResultSet.Concur_UpDatable); stmt1.setInt (1, Integer.parseint (jtf1.getText ())); ResultSet RST1 = STMT1.executeQuery (); rst1.Next (); int m = rst1.getInt (1); int n = rst1.getInt (2); n+= 1; rst1.Updateint (1, m); rst1.Updateint (2, n); rst1.updaterow (); Framedemo.a.ta.append ("-> exclua o registro de empréstimo com sucesso/n"); } else {Famedemo.a.ta.append ("-> excluir erro/n"); JoptionPane.ShowMessagedialog (NULL, "Este registro de empréstimo não existe!", "Aviso", JoptionPane.warning_message); }} Catch (Exceção x) {Famedemo.a.ta.append ("-> Excluir erro/n"); x.printStackTrace ();} addinformation.this.dispose (); } if (x == 6) {// exclua o registro do aluno string sql = "exclua de std where id =?"; String sql1 = "selecione * de BS onde stdid =?"; tente {conexão conn1 = getConnection (); Preparado STMT1 = Conn1.Preparestatement (SQL1); stmt1.setInt (1, Integer.parseint (jtf1.getText ())); ResultSet RST1 = STMT1.EXECUTEQUERY (); if (rst1.Next ()) {// A pessoa está no registro de empréstimo, JoptionPane.showMessagedialog (null, "A pessoa está no registro de empréstimos!", "Aviso", JoptionPane.warning_message); } else {conexão conn = getConnection (); Preparado STMTENT STMT = Conn.Preparestatement (SQL); int stdid = Integer.parseint (jtf1.getText ()); stmt.setInt (1, stdid); int t = stmt.executeUpdate (); if (t == 0) {Famedemo.a.ta.append ("-> excluir erro/n"); JoptionPane.showMessagedialog (Null, "O registro do aluno não existe!", "Aviso", JoptionPane.warning_message); } else Framedemo.a.ta.append ("-> Excluir registro com sucesso/n"); }} Catch (Exceção x) {Famedemo.a.ta.append ("-> Excluir erro/n"); x.printStackTrace ();} addinformation.this.dispose (); } if (x == 7) {// modifique o registro de inventário de livros string sql = "update book set num =? where id =?"; tente (conexão conn = getConnection (); preparadostatement sTmt = Conn.Preparestatement (sql)) {int num = Integer.parseint (jtf2.getText ()); int bookId = Integer.parseint (jtf1.getText ()); stmt.setInt (1, num); stmt.setInt (2, bookid); int t = stmt.executeUpdate (); if (t == 0) {Famedemo.a.ta.append ("-> erro de modificação/n"); JoptionPane.ShowMessagedialog (Null, "O registro do livro não existe!", "Aviso", JoptionPane.warning_message); } else Framedemo.a.ta.append ("-> registro de modificação é bem-sucedido/n"); } Catch (Exceção x) {Famedemo.a.ta.append ("-> Erro de modificação/n"); x.printStackTrace ();} addinformation.This.Dispose (); } if (x == 8) {// modifique a data a ser retornada string sql = "update bs set date =? Onde bookId =? e stdid =?"; tente (conexão conn = getConnection (); preparadostatement stmt = conn.preparestatement (sql)) {date date = date.valueof (jtf3.getText ()); Calendário calendário = new Gregoriancalendar (); calendário.setTime (data); calendário.add (calendário.date, -30); java.util.date ustildate = (java.util.date) calendar.gettime (); ustildate = (java.util.date) calendar.gettime (); Data newDate = new Date (ustildate.gettime ()); int stdid = Integer.parseint (jtf2.getText ()); int bookId = Integer.parseint (jtf1.getText ()); stmt.setDate (1, newDate); stmt.setInt (2, bookid); stmt.setInt (3, stdid); int t = stmt.executeUpdate (); if (t == 0) {Famedemo.a.ta.append ("-> erro de modificação/n"); JoptionPane.ShowMessagedialog (Null, "O registro de empréstimo não existe!", "Aviso", JoptionPane.warning_message); } else Framedemo.a.ta.append ("-> registro de modificação é bem-sucedido/n"); } Catch (Exceção x) {Famedemo.a.ta.append ("-> Erro de modificação/n"); x.printStackTrace ();} addinformation.This.Dispose (); } if (x == 9) {// Query string sql = "Selecione * do livro onde o nome =?"; ResultSet RST = NULL; tente (conexão conn = getConnection (); preparadostatement stmt = conn.preparestatement (sql)) {string name = jtf1.getText (); stmt.SetString (1, nome); rst = stmt.executeQuery (); if (rst.Next ()) { frameDemo.a.ta.append("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Framedemo.a.ta.append ("/t"+rst.getint (1)+"/t"+rst.getString (2)+"/t"+rst.getint (3)+"/n"); Framedemo.a.ta.append ("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- x) {FRAMEDEMO.A.TA.APPEND ("-> Erro de consulta/n"); X.PrintStackTrace ();} addinformation.This.dispose (); stmt = Conn.Preparestatement (sql)) {stmt.setInt (1, Integer.parseint (jtf1.getText ()); Framedemo.a.ta.append ("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- JoptionPane.ShowsAgedialog (NULL, "O livro não existe!", "Aviso", JoptionPane.warning_message); // consulta string sql = "selecione BookId, stdid, data de BS onde stdid =?"; rst = stmt.executeQuery (); frameDemo.a.ta.append("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Calendário.Settime (x); FRAMEDEMO (java.util.date) calendar.gettime (); Framedemo.a.ta.append ("/t"+rst.getint (1)+"/t"+rst.getint (2)+"/t"+x+"/t"+newDate+"/n"); Framedemo.a.ta.append ("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- sql = "Selecione * std where ID =?"; frameDemo.a.ta.append("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Framedemo.a.ta.append ("/t"+rst.getint (1)+"/t"+rst.getString (2)+"/n"); Framedemo.a.ta.append ("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- x) {FRAMEDEMO.A.TA.APPEND ("-> Erro de consulta/n"); X.PrintStackTrace ();} addinformation.This.dispose (); }}O exposto acima é todo o conteúdo deste artigo. Espero que seja útil para o aprendizado de todos e espero que todos apoiem mais o wulin.com.