connection database error

connection database error

import java.awt.EventQueue; // import packages
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class Register extends JFrame {   // create component in frame
    JFrame frame;
    JLabel CustomerNameLabel = new JLabel();
    JTextField name = new JTextField();
    JLabel CustomerAddressLabel = new JLabel();
    JTextField address = new JTextField();
    JLabel PhoneNumberLabel = new JLabel();
    JTextField number = new JTextField();
    JLabel Password1Label = new JLabel();
    JTextField passwrd1 = new JTextField();
    JLabel Password2Label = new JLabel();
    JTextField passwrd2 = new JTextField();
    JLabel UserNameLabel = new JLabel();
    JTextField user = new JTextField();
    JButton submit = new JButton();
    JButton clear = new JButton();
    JButton exit = new JButton();


    public static void main(String args[]) {    // initiate frame

        EventQueue.invokeLater(new Runnable() {
            public void run() {          // run
                try {
                    Register frame = new Register();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }


    private void jbInit() throws Exception {    // run Jbinit and throw exception , setting components in frame


        getContentPane().setLayout(null);
        setTitle("Register For Ordering ");

        getContentPane().add(CustomerNameLabel);
        CustomerNameLabel.setText("Name :");
        CustomerNameLabel.setBounds(10, 10, 89, 16);

        getContentPane().add(CustomerAddressLabel);
        CustomerAddressLabel.setText("Address :");
        CustomerAddressLabel.setBounds(10, 42, 89, 16);

        getContentPane().add(PhoneNumberLabel);
        PhoneNumberLabel.setText("Phone Number :");
        PhoneNumberLabel.setBounds(10, 74, 323, 20);

        getContentPane().add(UserNameLabel);
        UserNameLabel.setText("Username :");
        UserNameLabel.setBounds(10, 106, 89, 16);

        getContentPane().add(Password1Label);
        Password1Label.setText("Password :");
        Password1Label.setBounds(10, 138 , 89, 16);

        getContentPane().add(Password2Label);
        Password2Label.setText("Confirm password :");
        Password2Label.setBounds(10, 170, 150, 20);

        getContentPane().add(name);
        name.setBounds(130, 10, 250 , 20);

        getContentPane().add(address);
        address.setBounds(130, 42 , 250 , 20);

        getContentPane().add(number);
        number.setBounds(130, 74 , 150 , 20);

        getContentPane().add(user);
        user.setBounds(130, 106 , 150 , 20);

        getContentPane().add(passwrd1);
        passwrd1.setBounds(130, 138 , 150 , 20);

        getContentPane().add(passwrd2);
        passwrd2.setBounds(130, 170 , 150 , 20);

        getContentPane().add(clear);
        clear.addActionListener(new ClearActionListener());

        clear.setText("CLEAR");
        clear.setBounds(160, 347, 99, 26);

        getContentPane().add(submit);
        submit.addActionListener(new SubmitActionListener());

        submit.setText("SUBMIT");
        submit.setBounds(50, 347, 99, 26);

        getContentPane().add(exit);
        exit.addActionListener(new ExitActionListener());

        exit.setText("EXIT");
        exit.setBounds(270, 347, 99, 26);

    }
        public Register() {   // setting for frame
            super();

        setBounds(100, 100, 430, 430);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        try {                        // try and catch block
            jbInit();
        } catch (Throwable e) {
            e.printStackTrace();
        }

    }

    private class ClearActionListener implements ActionListener {   // action for button clear
        public void actionPerformed(ActionEvent e) {
            clear_actionPerformed(e);
        }
    }
    private class ExitActionListener implements ActionListener {  // action for button exit
        public void actionPerformed(ActionEvent e) {
            exit_actionPerformed(e);
        }
    }

    private class SubmitActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e)
        {
            String value1=user.getText();
            String value2=passwrd1.getText();
            try{

             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection con = DriverManager.getConnection("jdbc:odbc:NWIND","","");
                 Statement st=con.createStatement();
                 String query="insert into User values("+"Username,Password"+") values ('"+user+"','"+passwrd1+"')";
                 int result=st.executeUpdate(query);
                 st.close();
            }
             catch(Exception ea){}
        }

    }

    protected void clear_actionPerformed(ActionEvent e) {    // clear button
         name.setText("");
         address.setText("");
         number.setText("");
         user.setText("");
         passwrd1.setText("");
         passwrd2.setText("");

        repaint();
    }
    protected void exit_actionPerformed(ActionEvent e) {   // exit button
        System.exit(0);
    }
}
View Answers

December 7, 2011 at 4:59 PM

which type of error occurs? Specify it. Is NWIND is your dsn?









Related Tutorials/Questions & Answers:
connection database error
connection database error  import java.awt.EventQueue; // import...{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection...;which type of error occurs? Specify it. Is NWIND is your dsn
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...; PreparedStatement stmt=null; Connection con =null; ResultSet rs=null
Advertisements
DataBase Connection
DataBase Connection  How to connect java and Oracle 10g? Tell me Jdbc connection
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)  how do i implement connection pooling... to access the same application/database, I get a java.lang.NullPointer
Connection to Database
. However, most of times my web pages displays the error message" Too many Connection... and viewing hundreds of pages, I wont get any connection error and the truth... I manually make a connection to MySQL database in my web pages? How joomla
error in driver connection
error in driver connection  String driver = "org.gjt.mm.mysql.Driver"; Class.forName(driver).newInstance(); //error at this line Connection con=null; ResultSet rst=null; Statement stmt=null
database connection
database connection  how to connect the jsp page with database
database connection
database connection  i wanted to no how to connect sqlite database through netbeans? is it posible to connect it to a database that is on a remote pc? thank you
ftp connection error php
ftp connection error php  Getting a ftp connection error in php
database connection
database connection  hi all ready created database table using mysql database,employee payroll,attendance,employee details used database i need how to import and export excel file into database using jsp? pls help me any one
connection proxy error in hibernate
connection proxy error in hibernate  while we get connection through hibernate we arise an error connection proxy error while we are using multiple connection's
DataBase connection with sql - Struts
DataBase connection with sql  How to connect sql and send db error in struts? what are the tag should i code in struts-confic.xml
JAVA DATABASE CONNECTION WITH JTABLE
JAVA DATABASE CONNECTION WITH JTABLE  HOw To Load Database Contents From Access Database to JTable without using Vector
struts2-db connection error - Struts
struts2-db connection error  i m unable to connect to the database in one of my application using struts2???These concepts are pretty new to me..so i wanted to know where the problem would hav occured?  Hi Friend
connection error - WebSevices
connection error   while conncting a tool(jet profiler for my sql 1.0 released) with my running application ,it reflects following error: connected,but failed to login,read time out
SQL connection error in android
SQL connection error in android  hi, i am android developer . recently i made one application connect with sql server 2005 using jtds...:sql:Exception : BUFFERDIR connection property invalid. if you have any answer
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp... a connection with database. Plz reply. Thanks in advance...   Hi
ModuleNotFoundError: No module named 'database-connection'
: No module named 'database-connection' error? Thanks   Hi..., ModuleNotFoundError: No module named 'database-connection' error...ModuleNotFoundError: No module named 'database-connection'  Hi, My
ModuleNotFoundError: No module named 'database-connection'
: No module named 'database-connection' error? Thanks   Hi..., ModuleNotFoundError: No module named 'database-connection' error...ModuleNotFoundError: No module named 'database-connection'  Hi, My
connection proxy error in hibernate
connection proxy error in hibernate  while we get connection through hibernate we arise an error connection proxy error while we are using multiple error message is like below statements SEVERE: Servlet.service() for servlet
J2ME with Database Connection - MobileApplications
J2ME with Database Connection  I'm using SonyEricssion Java ME SDk for CLDC with WTK2. Can u give me a sample program for Database Connection using MS-Access with MIDlet code
database connection in struts - Struts
database connection in struts  Connecting database in Struts  in my project 4 table 1.user register 2.login page 3.forgot password 4.welcome page. all in struts but i dont no how sql database connected in struts plz
database connection - SQL
-database connection in eclipse IDE? Thanks...database connection  hi friends, This is poornima i want to connect sql server to my eclipse editer how to connect and where i have to write code
Connection to database - Java Beginners
Connection to database   HI I have just Started working on a Project on Jsp We hve some JSP Pages & trying to connect to our Database . We are using SQL server 2000 ? We are not able to connect our database Tables
java database connection - JDBC
java database connection  sir i want to join my project with MS access database. i am making my project in netbeans.please tell me the coding to do... the data into the MS Access database and retrieve the data from the database table
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
Regading Database connection
Regading Database connection  if we create the query table means how we retrive the query content from database
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...; RTextLine text = new RTextLine(); Connection con=null; Statement
ModuleNotFoundError: No module named 'wf-database-connection'
: No module named 'wf-database-connection' How to remove the ModuleNotFoundError: No module named 'wf-database-connection' error? Thanks   Hi...ModuleNotFoundError: No module named 'wf-database-connection'  Hi
ModuleNotFoundError: No module named 'wf-database-connection-honeycomb'
, ModuleNotFoundError: No module named 'wf-database-connection-honeycomb' error...ModuleNotFoundError: No module named 'wf-database-connection-honeycomb' ...: ModuleNotFoundError: No module named 'wf-database-connection-honeycomb' How to remove
ModuleNotFoundError: No module named 'aafp-database-connection'
: No module named 'aafp-database-connection' How to remove the ModuleNotFoundError: No module named 'aafp-database-connection' error? Thanks  ...ModuleNotFoundError: No module named 'aafp-database-connection'  Hi
Database connection class in a live project ..??
Database connection class in a live project ..??  In a Live mvc project where should i put the database connection class ? I want to know in the best coding practice
database connection in javascript - Java Beginners
database connection in javascript  hi, How can i connect the database and insert the data's by using javascript. thank u in advance. ragards, sakthi
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
Database Connection - JDBC
Database Connection  In java How will be connect Database through JDBC?  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml Thanks
database connection by using java bean
database connection by using java bean  i need a code for bean class to connect to mysql database. subsequently to use dis bean class whereever i need 2 connect 2 database
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11...{ Class.forName("com.mysql.jdbc.Driver"); Connection connection
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.
Java Connection to Oracle database
Java Connection to Oracle database  HI I am ubable to connnect jdbc to Oracle database.i had gone to control panel >>Administrative... type properly and the Test Connection failed.So Kindly tell me what to type in TNS
java database connection - Struts
java database connection  how to connect a database in struts program?  First Add two jar file1> commons-dbcp-1.2.x.jar2> mysql...; value="jdbc:mysql:///database_name?autoReconnect=true"
java database connection
java database connection  package com.tsi.constants; public class Constant { public static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static final String DBURL = "jdbc:oracle:thin
java database connection
java database connection  package com.tsi.constants; public class Constant { public static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static final String DBURL = "jdbc:oracle:thin
server database connection - JSP-Servlet
" in that case how we will get the database connection   Hi Friend...server database connection  sir generally we will connect to the database by using the following steps 1.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
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
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
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
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect... .but it has shown error in TNS .what exactly i did is that i have gone... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect... .but it has shown error in TNS .what exactly i did is that i have gone... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... .but it has shown error in TNS .what exactly i did is that i have gone to control... that connection is correct or not. The testing has failed .so what could be TNS
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... .but it has shown error in TNS .what exactly i did is that i have gone to control... that connection is correct or not.The testing has failed .so what could be TNS

Ads