java database error
1 Answer(s)      7 years ago
Posted in : JDBC


View Answers

April 7, 2009 at 12:41 PM

hi prashant,

Use the following code to insert the data into MS-Access database:

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

public class InsertData extends JFrame implements ActionListener {

JButton insertButton;
JTextField text1,text2;
JLabel label1,label2,label;
JPanel p1,p2,p3,panel;

public InsertData(){
insertButton = new JButton("Insert");
text1 = new JTextField(15);
text2 = new JTextField(15);

label1 = new JLabel("Name:");
label2 = new JLabel("Address:");
label = new JLabel("",JLabel.CENTER);

p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
panel = new JPanel();
panel.setLayout(new GridLayout(2,1));

p2.setLayout(new GridLayout(2,1));

public static void main(String args[]){
InsertData data = new InsertData();
public void actionPerformed(ActionEvent e){
PreparedStatement pstm;
ResultSet rs;
String sql;
label.setText("Please enter the textfields.");
Connection connect =DriverManager.getConnection("jdbc:odbc:access");
pstm=connect.prepareStatement("insert into data values(?,?)");
label.setText("Data is inserted into MS Access database");
catch(Exception ex){


Related Tutorials/Questions & Answers:
java database error - JDBC
java database error  hi all i am writing one swing application where i want to insert data into database(MS-Access) but dont know how to do... the following code to insert the data into MS-Access database: import java.sql.
Error with LogIn with mysql database
Error with LogIn with mysql database  Hi, I have followed steps from your tutorial titled SpringMVClogin with database. I am not using Jetty, as I... 404 page error. In Tomcat console it states the reason as: "Error creating bean
error oracle database connection?
error oracle database connection?  hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created... method stub } } desing jsp page; newuser_reg.jsp <%@ page language="java
error log and send Database
error log and send Database  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details
Applet to database error - Applet
Applet to database error  Hi... I had an application where i need to connect to the database for the values to display in the applet.... Following... necessary for finding the error... as itz only drawing strings or lines
Database error - WebSevices
Database error  Hello, How i connect my database file& tables to Zend library file Using PHP language. In which library file i should change that code. Any one know the exact changes. Tell me.   http
connection database error
connection database error  import java.awt.EventQueue; // import packages import java.awt.event.ActionEvent; import java.awt.event.ActionListener...;which type of error occurs? Specify it. Is NWIND is your dsn
Database Error - Hibernate
Database Error  Hi, I am working with Struts 1.2---- AJAX-----Hibernate 3.0 --- MySQL 5.0. At the time of inserting/fetching from Database... exceeded; try restarting transaction That means the database becomes locked. Can
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11 = stmt.executeQuery(query11); while({ product_code[j
error in accessing database - JSP-Servlet
error in accessing database  hiiii im tanushri im tryng to connect my database to the servlet i hv succeeded in connectivity but im stuck to nother error called Got minus one from read call although i hv feeded data to my
Display error message if data is already inserted in database
Display error message if data is already inserted in database   Display error message if data is already inserted in database Pls help me Thanks
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
getting error while inserting values in database
) { out.println("An Error Had occurred while accessing the database...getting error while inserting values in database; Context envContext = (Context) initContext.lookup("java:/comp/env
Java Error - Java Beginners
Java Error  Hello Sir ,How i Can solve Following Error Can not find Symbol - in.readLine(); Here Error Display at in  Hi Friend, It seems that you haven't defined the object 'in'.Anyways, Send your code so that we
runtime error in java
runtime error in java  What is Run time error in Java?   Run time error is a syntax error that during the execution of a program.It hash different types of a program like as Logic error,Fatal Errors,source code,wrong
java error - Java Beginners
java error  Hello sir, on compiling any program from command prompt.... But if I want to run that program the fetches me the following error. For example for file: C:\Program Files\Java\jdk1.6.0_17\bin>javac
java error - Java Beginners
java error  G:\threading>javac Note: uses or overrides a deprecated API. Note: Recompile with -Xlint... been obsoleted. To get the details of your error, compile your class with Xlint
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
java compilation error - Applet
java compilation error  I am getting compilation error in the following code.: public void paint(Graphics g) { switch(screen...; } } Error is: Illegal start of expression Plz. find why am I getting this error
Java Error - Java Beginners
Java Error  E:\SUSHANT\Core Java\FileHandling\Error>javac... ch=; ^ 1 error import; //System.out.println("Enter characters, 'q' to quit."); try
Java Error - Java Beginners
Java Error  Here Error near Read Method import java.util.*; import*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println
Database,Java  help me for the following things if one customer... me the how to write the query in MySQL database and i want coding for this one in Java.because i am using Java as the front end.   1)page.jsp: <
java and database
java and database  sir i want to prepare a sign in form and i want to check that user name is exist or not in database if it is exist in database...("")) { JOptionPane.showMessageDialog(null,"Enter login name or password","Error",JOptionPane.ERROR_MESSAGE
JAVA Annotation Error
JAVA Annotation Error  while compiling simple java program i get annotation error i.e class will only be accepted if annotation processing is explicitly to solve
java runtime error - JDBC
java runtime error  when i m running my program by using jdk1.6.0 then it is giving the error of classunsupported major.minor version remove... version error, please suggest how will i compensate this problem
java database
java database  help me with this...i never learn build java database... to design and implement objects needed for a program that maintains a database.../teacher information, search it, alter it, etc. The database is maintained as a list
java error - Java Beginners
java error  Thanks for providing me the answer for the question... be dereferenced If Programme saved in SortFileData also shows some error Please rectify the errors and provide the coding that run properly Write a Java program
Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error
JAVA Error - Java Beginners
JAVA Error  i have made my own calculator GUI..and i want the text..."); btnBack.setForeground(red); it send me an error message that goes like this unknown...: Thanks.   Hello Just use
java runtime error - JDBC
java runtime error  when i m running my program using type1 driver it is showing a runtime error of SQLException of unable to create the connection object.please give the solution