java &ms access
Seasons Greetings,
Am, creating an application for a food festival using Java swing as front end and MS access as Backend.
The scenario is:interested employees have to register for the event ,they choosing their choice of food listed using check box.They have to be given a unique id upon successful registration.
The list of organisation is present in the JComboBox.I ve managed to populate the JComboBox using MS Access.
The problem is only 8 per organisation are allowed to register else which a message box is displayed.
Do help me in this regard.
The template of interface is as follows:
Name:JtextField
Organisation:JComboBox
choice of food:4 check box,Nort indian,south indian,chinese,juice and dessert.
warm regards,
Sam
View Answers
August 4, 2010 at 4:51 PM
Hi Friend,
Try the following code:
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class Festival extends JFrame{
JTextField text1,text2,text3,text4,text5;
JLabel label1,label2,label3,label4,label5;
JPanel panel;
JButton button;
Festival() {
text1=new JTextField(15);
text2=new JTextField(15);
text3=new JTextField(15);
text4=new JTextField(15);
text5=new JTextField(15);
label1=new JLabel("Name");
label2=new JLabel("Address");
label3=new JLabel("Phone No");
label4=new JLabel("Email");
label5=new JLabel("Oraganization");
button=new JButton("Save");
panel=new JPanel(new GridLayout(6,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(label5);
panel.add(text5);
panel.add(button);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int count=0;
String v1=text1.getText();
String v2=text2.getText();
String v3=text3.getText();
String v4=text4.getText();
String v5=text5.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from user where organization='"+v5+"'");
while(rs.next()){
count++;
}
if(count>=8){
JOptionPane.showMessageDialog(null,"The members in this organization has been already registered");
text5.setText("");
}
else{
int i=st.executeUpdate("insert into user(name,address,phoneNo,email,organization) values('"+v1+"','"+v2+"','"+v3+"','"+v4+"','"+v5+"')");
JOptionPane.showMessageDialog(null,"You are successfully registered");
}
}
catch(Exception ex){
System.out.println(ex);
}
}
});
add(panel);
setVisible(true);
pack();
}
}
August 4, 2010 at 4:52 PM
continue..
class FoodFestival{
public static void main(String[] args) {
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel l=new JLabel("If you are not registerd");
JButton butt=new JButton("Register Now");
JLabel l1=new JLabel("Name");
JLabel l2=new JLabel("Organization");
JLabel l3=new JLabel("Choice Of Food");
final JTextField text=new JTextField();
JCheckBox chk1=new JCheckBox("North Indian",false);
JCheckBox chk2=new JCheckBox("South Indian",false);
JCheckBox chk3=new JCheckBox("Chinese",false);
JCheckBox chk4=new JCheckBox("Juice and Dessert",false);
final JComboBox jc=new JComboBox();
JButton b=new JButton("Make Choice");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select organization from organization");
jc.addItem("Select");
while(rs.next()){
jc.addItem(rs.getString("organization"));
}
}
catch(Exception e){}
l.setBounds(50,50,200,20);
butt.setBounds(200,50,150,20);
l1.setBounds(50,100,100,20);
text.setBounds(200,100,100,20);
l2.setBounds(50,130,100,20);
jc.setBounds(200,130,100,20);
l3.setBounds(50,160,200,20);
chk1.setBounds(200,160,200,20);
chk2.setBounds(400,160,200,20);
chk3.setBounds(600,160,200,20);
chk4.setBounds(800,160,200,20);
b.setBounds(200,200,100,20);
f.add(l);
f.add(butt);
f.add(l1);
f.add(text);
f.add(l2);
f.add(jc);
f.add(l3);
f.add(chk1);
f.add(chk2);
f.add(chk3);
f.add(chk4);
f.add(b);
f.setSize(1000,700);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
butt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new Festival();
}
});
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String name=text.getText();
String org= jc.getSelectedItem().toString();
System.out.println(org+" ");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from user where name='"+name+"' and organization='"+org+"'");
String uname="",orgname="";
while (rs.next()) {
uname = rs.getString("name");
orgname = rs.getString("organization");
}
if(!name.equals(uname) && !org.equals(orgname)) {
JOptionPane.showMessageDialog(null,"You are not registered.","Error",JOptionPane.ERROR_MESSAGE);
text.setText("");
}
}
catch(Exception ex){}
}
});
}
}
Thanks
Related Tutorials/Questions & Answers:
java &ms access - JDBCjava &
ms access Seasons Greetings,
Am, creating an application for a food festival using
Java swing as front end and
MS access as Backend... ve managed to populate the JComboBox using
MS Access.
The problem is only 8 per
ms accessms access how to delete the autonumber from
ms access using
java delete code
Advertisements
how to access the MS ACCESS database with java how to
access the
MS ACCESS database with
java how to
access the
MS ACCESS database with
java how can we insert,delete,update,search records of
ms access with
java
Java MS Access database connectivity
Follow
Accessing Ms access data in JAVA GUI Envi.Accessing
Ms access data in
JAVA GUI Envi. Q.How to insert data into
ms access data in
java using swing ?
Q.How to slove (
access denided ("java.lang.RuntimePermission" "accessClassInPackage.sun.jdbc.odbc")" these exception
MS Access connct using flex with javaMS Access connct using flex with java Hi All,
Can anybody help me how to connect to the
MS access database and getting the data using flex in
java technology with tomcat server
MS accessMS access how do i
access my
Ms-
Access file placed in the same jar file where my application code/class file r present??? Want to
access it via Code. Can anyone help me ? Please give reply urgent...
give me reply
ms access has to login
. i already created
ms access page and inserted values throught... and password" from my
ms access............and detail in register(table in my
ms... and password " he has to login
. i already created
ms access page and inserted values
ms access has to login
. i already created
ms access page and inserted values throught... and password" from my
ms access............and detail in register(table in my
ms... and password " he has to login
. i already created
ms access page and inserted values
ms access has to login
. i already created
ms access page and inserted values throught... and password" from my
ms access............and detail in register(table in my
ms... and password " he has to login
. i already created
ms access page and inserted values
ms access has to login
. i already created
ms access page and inserted values throught... and password" from my
ms access............and detail in register(table in my
ms... and password " he has to login
. i already created
ms access page and inserted values
Ms Access Ms Access How to get query for Primary key from MsAccess?
SELECT column_name
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE table_name = 'data';
SELECT column_name
FROM INFORMATION_SCHEMA.KEY_COLUMN
MS-AccessMS-Access I am trying to upload a image to
ms-acess using jsp,and my problem is that it shows some error int the browser that "java.sql.SQLException: [Microsoft][ODBC Microsoft
Access Driver]COUNT field incorrect ".I think i set
MS ACCESSMS ACCESS i have done :
Insert form data into
MS database...-> data sources.
2)Click Add button and select the driver Microsoft
Access... language="
java" contentType="text/html; charset=ISO-8859-1"
pageEncoding
MS ACCESSMS ACCESS i have done :
Insert form data into
MS database...-> data sources.
2)Click Add button and select the driver Microsoft
Access... language="
java" contentType="text/html; charset=ISO-8859-1"
pageEncoding
MS ACCESSMS ACCESS i have done :
Insert form data into
MS database
Follow...-> data sources.
2)Click Add button and select the driver Microsoft
Access... language="
java" contentType="text/html; charset=ISO-8859-1"
pageEncoding
java to MS Access conectivity - Swing AWTjava to
MS Access conectivity give me source code to stored... database on the
ACCESS. Hi Friend,
Follow these steps:
1. Open...(ODBC)
2. Open User DSN tab
3. Add a user DSN
4. Select Microsoft
Access Driver
How to Access MS Access in jar.How to
Access MS Access in jar. how do i
access my
Ms-
Access file... to
access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to
access a
Ms-
access via JDBC but cant find the file wen
Jdbc MS-Access questionJdbc
MS-
Access question How to delete records from the three table in
MS-
Access? They are in relationship with each other regarding to data field
Jdbc MS-Access questionJdbc
MS-
Access question How to delete records from the three table in
MS-
Access? They are in relationship with each other regarding to data field
excel to ms accessexcel to
ms access hello sir i am developing a application which requires extracting data from excel sheet and place in the
ms access database using
java programming
for example: in excel sheet i have 2 columns and more than
MS Access` - IDE QuestionsMS Access` hello sir,
how to configure
MS Access database in Net Beans5.5...
and i have a doubt, where should we run the below code...either in IDE or in any editor like EDITPLUS.
waitin for your reply....
thank you
J2ME connectivity to ms accessJ2ME connectivity to
ms access How to establish client server connectivity to
access ms access database on the server side? I have made the odbc connection. Plz help me in the coding part.. Dont know how to start
MS Access - JDBC information about
MS access database...but still i am having doubt in that topic.
My problem is : Is there any jar to connect
MS Access and
java ...
because... to be remember
1.to configure the
ms access database to your system
control
MS ACCESS - JDBCMS ACCESS java.sql.SQLException: [Microsoft][ODBC Microsoft
Access Driver] Syntax error (missing operator) in query expression 'origin='src' destination='dest''.
THAT MY PROBLEM
MS Access` - JDBCMS Access` Hello Sir,
Thank you very much for your valuable information.
Actually i am doin a project to generate Hall tickets.So, I need to insert image into
MS Access Database. Now the task is how to retrieve the image
MS Access - JSP-Servlet
stepts
1.to configure the
ms access database to your system
control panel... in Connectivity in
MS Access :
import java.sql.*;
public class...
MS Access hello sir,
i want to use MS.Access as my database..so my
inserting picture in ms accessinserting picture in
ms access hi i am sanatan, how to insert picture in
ms access by jsp.
<%@page import="java.sql.*,java.io.*"%>
<%
try{
InputStream sImage;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
MS Access - WebSevicesMS Access hello sir,
i am trying to write a code which should take images from a particular folder and data from MSAccess..please help me..thank..." which have
access database and for images we have created a field in the table
Upload file to MS AccessUpload file to
MS Access Iam beginner and need to upload file to msaccess using jsp . Iam using netbeans platform.
Kindly explain do I need to mention Attachment format in the table
Migrating from mysql to MS AccessMigrating from mysql to
MS Access Hi
I am hoping for some help
I need to write a conversion program (SQL statements) to import existing data in a MYSQL database to a
MS Access database.
any suggestions would be appreciated
accessing ms access through jspaccessing
ms access through jsp i have 3 tables in my database employee,project,task
if i put employee id the search field .i should get details from other table
what all queries should i use in servlet file and i am using
How to use JTable with MS-AccessHow to use JTable with
MS-Access I have Three Column in Database (
MS-
Access).
1. Name
2. City
3. Contact
I want to Display....
Here is an example that retrieves the data from
MS Access database
How to use JTable with MS-AccessHow to use JTable with
MS-Access I have Three Column in Database (
MS-
Access).
1. Name
2. City
3. Contact
I want to Display....
Here is an example that retrieves the data from
MS Access database
jdbc warning regarding to ms accessjdbc warning regarding to
ms access shows warning msg while compiling using
ms access : warning: sun.jdbc.odbc.JdbcOdbcDriver is Sun proprietary API and may be removed in future release.
here is my code
import java.sql.
MS-ACCESS Query Problem - SQLMS-
ACCESS Query Problem hi sir
i have table which is initially have empty records
Deleted
Attributes:
Roll
Name
Add
Age
Course
Class... = DriverManager.getConnection("jdbc:odbc:
access");
Statement st
problem in jsp using ms-accessproblem in jsp using
ms-access after starting server(tomcat) wen v... and select the driver Microsoft
Access Driver(*.mdb).
3)After selecting... the driver Microsoft
Access Driver(*.mdb).
3)After selecting the driver, click
audio files in jdbc connectivity with ms-access - JDBCaudio files in jdbc connectivity with
ms-access i need to know how to retrieve audio files through jdbc connectivity with
ms-
access and how to play... static void main(String[] args) {
try{
String url="jdbc:odbc:
access";
File