Share on Google+Share on Google+

maria
jdbc front end
1 Answer(s)      6 years and 10 months ago
Posted in : JDBC
a code written using JDBC,ODBC,SQL and swing only that allows the user to select the required driver related to a specific database that can execute the SQL queries related to that database.

Ads

View Answers

June 10, 2010 at 1:10 PM


Hi Friend,

Try the following code:

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

class FormDemo extends JFrame {
JButton ADD;
JPanel panel;
JFrame f;

FormDemo(){
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Address:");
text2 = new JTextField(20);

ADD=new JButton("Insert");
ADD.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String v1=text1.getText();
String v2=text2.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=connect.createStatement();
int i=st.executeUpdate("insert into data(name,address) values('"+v1+"','"+v2+"')");
JOptionPane.showMessageDialog(null,"Inserted Successfully");
}
catch(Exception ex){
JOptionPane.showMessageDialog(null,"Error");
}

}
});
f=new JFrame();
panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(ADD);
f.add(panel,BorderLayout.CENTER);
f.setTitle("FORM");
f.setVisible(true);
f.pack();
}
public static void main(String[]args){
FormDemo ff=new FormDemo();
}
}

If you haven't created DSN connection then follw these steps:

1. Open Data Sources (Start->Control Panel->Administrative

Tool->Data Sources(ODBC)

2. Open User DSN tab
3. Add a user DSN
4. Select Microsoft Access Driver(*.mdb)
5. Select database name and Create the DSN name (e.g emp)
6. Click "Ok" and then restart your compiler.

Thanks









Related Tutorials/Questions & Answers:
jdbc front end - JDBC
jdbc front end  a code written using JDBC,ODBC,SQL and swing only that allows the user to select the required driver related to a specific database..."); Connection connect =DriverManager.getConnection("jdbc:odbc:access","",""); Statement st
CONNECT TO FRONT END - Hibernate
CONNECT TO FRONT END  HI HOW TO COONECT HIBERNET WITH STRUCT FRONT eND. PLEASE PROVIDE CODE AS SOON AS POSSIBLE. REGARDS DILEEP  Hi Friend, Please visit the following link: http://www.roseindia.net/struts
Advertisements
front-end validation based on the xml in validation.xml.
front-end validation based on the xml in validation.xml.  How you will enable front-end validation based on the xml in validation.xml
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put in front of a featched data and when i clicked on this button then the data
not picking request parameters from the front end - JSP-Servlet
you have enter in front end). but i am getting response as welcome to unicel...not picking request parameters from the front end  hi, This is venkatramana. I am writing one small basic program. I am not getting proper output
extract data fom table when a button is clicked in front end page using mysql5.0 and tomcat6.0
extract data fom table when a button is clicked in front end page using... is stored in mysql5.0 databse, when a button is clicked in front end page using...://www.roseindia.net/jdbc/display-data-database.shtml Thanks
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp...("sun.jdbc.odbc.JdbcOdbcDriver"); con=DrivergetConnection("jdbc:odbc:DNSName","scott
i have developed the application in jsp(front-end -jsp,business logic-jsp).it is very slow when accessing the page - JSP-Servlet
i have developed the application in jsp(front-end -jsp,business logic-jsp).it is very slow when accessing the page  i have developed the application in jsp only.i did not use any classes.application is very slow when access
JDBC access database
JDBC access database       JDBC is a Java Database Connectivity. The JDBC Connectivity provides API classes and interfaces for connecting the front end in Java application with database connections
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time  I am new developer in .net,I Have requirement..like this ,when user pick date from date picker
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time
How Insert DateTime Vales into Mysql Databse from the front end application.But User Gives Date only from Datepicker,not Time  I am new developer in .net,I Have requirement..like this ,when user pick date from date picker
JDBC batch
to interact your Java Application in your front end with the backend... Connection provides you to connect  the front end in java application... JDBC batch       JDBC is simply a Java
front controller - JSP-Servlet
front controller  How to implement front controller in a web application
MySQL Front
with the MySQL database. Here is the list of MySQL Front end tools: What...    MySQL-Front is a front-end interface for the popular MySQL...-datasources.    Introducing SQLyog and a MySQL Front End
jdbc
is to reduce the network calls between the front end application and its database rather...jdbc define batch updates  define batch updates?exp   JDBC... links: http://www.roseindia.net/jdbc/Jdbc-batch-update.shtml http
Front Page Web Hosting
Front Page Web Hosting Microsoft Front Page is leading WYSIWYG editor for the development of web site using HTML and DHTML. Front Page is used... providers provides Front Page Support on their web servers. Front Page extensions
endif to end the conditional statement.
endif to end the conditional statement.  When are you supposed to use endif to end the conditional statement
Remove Extra Space At End
Remove Extra Space At End  Remove Extra Space At End
jdbc - JDBC
jdbc  How can i store images in a database column without a front end...: http://www.roseindia.net/jdbc/save_image.shtml Retrieve Image using Java... = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test", "root", "root
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
Problem with appending data to the end of file
Problem with appending data to the end of file  MY JSP CODE WITH THE JAVA CLASS: JSP CODE: <html> <body> <%@ page language="java" import="java.io.*,data.*" %> <% String name=request.getParameter("name
JDBC
JDBC  why we use batch in jdbc
jdbc
jdbc  Hai , Give a steps for jdbc connectivity
jdbc
jdbc  display the records using index in jdbc
JDBC
JDBC  How to add set of queries in a single query in JDBC
jdbc,odbc,MySQL,swing - Java Beginners
to the selected database driver.It is very well known as jdbc front end of a database...jdbc,odbc,MySQL,swing  write a code that displays a menu list of all available database drivers in a window,and allows the user to select any driver
JDBC
JDBC  can u send me the code of jdbc how to join two tables that are in relation
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
jdbc
jdbc  is it possible to use doget & dopost method with jdbc to call in a servlet programe
JDBC
JDBC  in class.forname which driver name we are writing for the connection from jdbc to sqlserver 2008
JDBC
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector
Tutorials   
Java Spring Hibernate Struts Training how to retrieve text and images from mysql database and show on html page using jsp servlet How to install Neo4j on Ubuntu 15.10? please help me in these prog MYSQL - mysql copy table to another table example by creating new table solution for mapping hibernate and pojos from net beans through database Connect GWT application with Oracle inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store This code have created jTable that connected with a database.every cell of last column have a button.But this button doesn't work properly.Where is the error java program Java Database Program jdbc Database connection class in a live project ..?? What is JDBC architecture? Unable to Create DSN for excel to ms access importing data and edit that data Database Scrolling Buttons how to use foreign key in java How to delete content of a log file from linux terminal? JSP-Oracle connectivity Student Management System Java code for Saving Marathi (Indian local language ) in Mysql and retrieving the same crud operations with foreign key constraint. I really need help with this assignment question Please help me out Please Backup Failed Mysqldump Got Errno 28 On Write Upgrade MySQL 5.1 to 5.5 in cpanel mysqldump all databases com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jpa.sequence' doesn't exist persistence xml class element persistence.xml for MySQL MySQL JDBC Driver pom dependency code Blob column jdk6 and oracle 8i connexion oracle 8i et jdk6 java [ cannot retrive date from sql ] why?? Order Entry System How to threow timeout exception when DB is not responding How to threow timeout exception when DB is not responding This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible make a method which takes user name & pwd as parameter & validate them against the database. If the corresponding user exist return true otherwise false. prabhakar validating credentials and displaying error message in login .jsp if not valid JDBC jdbc jdbc code register servlet vibhu connectiondetails from vibhu

Ads

 
Advertisement null

Ads