Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Help on this java code for online library search
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sreekandan.K
Help on this java code for online library search
0 Answer(s)      3 years and 3 months 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();
 }
} 

Advertisement
View Answers

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.
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
Advertisements
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
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 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
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
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
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
SSH library for Java
SSH library for Java  SSH library for Java
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
A better Java JSON library?
A better Java JSON library?   A better Java JSON library
email search code in php
email search code in php  email search with multiple option in php
run php code online
run php code online  Is it possible to run PHP Code online
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
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
Java FTP Library
Java FTP Library  Which all Java FTP Library available in market? Is there any free open source Java FTP Library? Thanks   Hi, Both open source and commercial Java FTP library are available on Internet. Most used open
FieldTalk Library For Java
FieldTalk Library For Java   i m developing s/w scada.in... will it happen. I searched on internet, then i found that Java FieldTalk Libray is being used for this. But it is not available.. plz help me, its urgent.. Thanks you
secure online payment code for jsp
secure online payment code for jsp   how to implements online payment in jsp
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 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 prints an n-level stair case made of text. The user should choose the text character..., http://www.roseindia.net/java
How to code a Product id search engine?
How to code a Product id search engine?  I always wonder how people here are such greatly helpful. I have about a 30 rare products in my online store(just showcasing, we don't sell) each with a specific id. I am trying to code
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
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:=@rownum+1 'rownum', X
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
javascript code for search in html file
javascript code for search in html file  Hi, I am looking for javascript code through which we can search data with specific name find in any rows... e .......... Search: P002 After search result would be show like below format
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
 

 

 

DMCA.com