Help on this java code for online library search

Ads

 
 

Share on Google+Share on Google+

Sreekandan.K
Help on this java code for online library search
0 Answer(s)      6 years and a month ago
Posted in : Java Beginners
I have written the following java code for simple library book search. but its having some errors ... please help me on this code.

import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;

public class Library
{
 JRadioButton rbauthor = new JRadioButton("Search by Author name");
 JRadioButton rbbook = new JRadioButton("Search by Book name");
 JTextField textfld = new JTextField(30);
 JLabel label = new JLabel("Enter Search Key");
 JButton searchbutton = new JButton("Search");
 JFrame frame = new JFrame();
 JTable table;
 DefaultTableModel model;
 String query = "select * from Library";

 public Library()
 {
  frame.setTitle("Online Public Access Catalog");
  frame.setSize(500,600);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());

  JPanel p1 = new JPanel();
  JPanel p2 = new JPanel();
  JPanel p3 = new JPanel();

  p1.setLayout(new FlowLayout());
  p1.add(label);
  p1.add(textfld);

  ButtonGroup bg = new ButtonGroup();
  bg.add(rbauthor);
  bg.add(rbbook);

  p2.setLayout(new FlowLayout());
  p2.add(rbauthor);
  p2.add(rbbook);
  p2.add(searchbutton);
  searchbutton.addActionListener(this);

  p3.setLayout(new BorderLayout());
  p3.add(p1,BorderLayout.NORTH);
  p3.add(p2,BorderLayout.CENTER);

  frame.add(p3,BorderLayout.NORTH);
  addTable(query);
  frame.setVisible(true);
 }
 public void addTable(String s)
 {
  try
  {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection conn = DriverManager.getConnection("jdbc:odbc:Library","","");
   Statement st = conn.createStatement();

   ResultSet rs = st.executeQuery(s);
   ResultSetMetaData md = rs.getMetaData();
   int cols = md.getColumnCount();
   model = new DefaultTableModel(1,cols);
   table = new JTable(model);
   String[] tabledata = new String[cols];
   int i=0;
   while(i<0)
   {
    model.removeRow(0);
    frame.remove(table);
    addTable(query);
   }
  }
  catch(Exception e)
  {
  }
 }
 public static void main(String args[])
 {
  new Library();
 }
} 
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Help on this java code for online library search
Help on this java code for online library search   I have written the following java code for simple library book search. but its having some errors ... please help me on this code. import java.sql.*; import java.awt.
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM  can u help me to code in jsp for online voting system
Advertisements
online library management
online library management  how to divert user from log in page to home page depending on their category(like student or staff in case of ol library) using java servlet
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
Java Programming Code HELP
Java Programming Code HELP  Hi, sir/madam. I am new here and currently developing a program whereby it can read the Java source file...: String, attribute name = variable name) Below are my source code. Hope
online voting system source code in java
online voting system source code in java  Please send me source code for online voting system in java. please replay as fast as. Thank you
online shopping project report with source code in java
online shopping project report with source code in java  Dear Sir/Mam, i want to a project in java with source code and report project name online shopping. thank you
Java code help
Java code help  Write a java program that will ask the user to input any number from 5 to 9 and then print the following structure depending on the user input. E.g. If the user input is 5, then print the following structure 1 2 3
java code to search in your hard disck
java code to search in your hard disck  Build a search engine which would scan your hard disk and build an inverted index for your files. The search engine should cluster your files according to some criteria and make some
code for timer in java netbeans for online test series countdown timer
code for timer in java netbeans for online test series countdown timer  code for timer in java netbeans for online test series countdown timer
Source Code for Search Engine Project in java - Java Beginners
Source Code for Search Engine Project in java  Hello Sir ,I want Java Project for Search Engine(like google),How I can Make it,Plz Give Me Complete Source Code Of Search Engine Project in Java.  Hi Friend, Please
ONLINE EXAM CODE SPLIT
ONLINE EXAM CODE SPLIT  hi.. im developing online exam for c programming in jsp.. i read the question from database as a string suppose String...(){ int i; for(i=0;<100;i++){ printf("hai"); } } how is it possible? plz plz help
run php code online
run php code online  Is it possible to run PHP Code online
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character..., http://www.roseindia.net/java
Please help me to modify my java code from php code
Modify Java code from PHP Code  i want to covert this php code int java/JSP. if (isset($_POST['orders'])) { $orders = explode('&', $_POST... the exact result as the above PHP code is giving. So please help me to convert
please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named famous.txt and prints out the line with the longest length. In the case...(); } } } ------------------------------- read for more information, http://www.roseindia.net/java/beginners/read
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
email search code in php
email search code in php  email search with multiple option in php
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert this php code int java/JSP . if (isset($_POST['orders'])) { $orders... help me to convert it into Java. if (request.getParameter("orders") != null
secure online payment code for jsp
secure online payment code for jsp   how to implements online payment in jsp
Online Java Compiler
Online Java Compiler provides the Java development environment online, which allows you to write and test Java code from anywhere. All you need is a competitive online Java compiler. Using Online Java Compiler you can instantly start
online attendance management in java.....
online attendance management in java.....  if any body have this project or project related to this please help.... i need it urgently.. plz help me out
Pleae help me to give logic and code for this program - Java Beginners
Pleae help me to give logic and code for this program  Write a function that given the string ?original? create a new string ?dramatic? that has two...://www.roseindia.net/java/beginners/StringReverseUsingStringUtils.shtml
Source Code for Implementing Search Feature in JSP using Java action/Servlet - JSP-Servlet
Source Code for Implementing Search Feature in JSP using Java action/Servlet  How do I write the source code to implement search feature in JSP using Java action/servlet? My query is: SELECT @rownum:[email protected]+1 'rownum', X
SSH library for Java
SSH library for Java  SSH library for Java