You are on page 1of 2

import javax.swing.table.

*;
import java.sql.*;
import javax.swing.JOptionPane;

private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {

this.setVisible(false);
}

private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {

// Before writting the followng line, you should import the line:
// import javax.swing.table.*; at the top of your application
DefaultTableModel model = (DefaultTableModel) jTable3.getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (int i = 0; i < rows; i++) {
model.removeRow(0);
}
}
// SQL Query
String st = "NON"; // Lib table
String query = "SELECT * FROM veh WHERE ISSUE_status = '" +st+ "';";
try {
// Connect to MySQL database
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/travelagency","root","mysq
l");
// Create SQL statement and execute query.
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

// Iterate through the result and display on screen


while (rs.next()) {
String no = rs.getString("v_no");
String name = rs.getString("V_name");
String disc = rs.getString("otr_disc");
String type = rs.getString("type");
String price = rs.getString("price");
String cap = rs.getString("v_cap");
String batchno = rs.getString("batchno");
String date = rs.getString("pdate");
String bPrice = rs.getString("rs_book");
String stt = rs.getString("status");
String issue = rs.getString("issue_status");
//System.out.println(Acno + "|" + bTitle + "|" + Auth1 + "|" +
Price + "|" + edition);
model.addRow(new Object[]{no, name, disc, type, price, cap,
batchno, date, bPrice, stt, issue});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


new MAINFORM().setVisible(true);
this.setVisible(false);
// TODO add your handling code here:
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

new ONBOOK().setVisible(true);
this.setVisible(false); // TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new avilableveh().setVisible(true);
}
});
}

You might also like