Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java.SQL.Exception:"General Error"

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java.SQL.Exception:"General Error"

    Hello all...I am doing a project on Hotel Management in JDBC...Front end is being designed using Swings in Eclipse and SQL Server Management 2008 fo the back end...My problem is i am getting the above mentioned exception...I dont know where i am getting wrong...Please help me out to solve this problem as soon as possible...i need to submit the project within 31st of july... Thanks in advance...

    Here is my code:

     
    btnSubmit = new JButton("SUBMIT");
    		btnSubmit.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				Connection con=null;
    				PreparedStatement ps=null;
    				//ResultSet rs=null;
    		     try{
    		    	 if(textField.getText().equals("") || textField_2.getText().equals("") || textField_5.getText().equals("") || textField_6.getText().equals("") || textField_7.getText().equals("") || passwordField.getPassword().equals("") || passwordField_1.getPassword().equals("")){
    						JOptionPane.showMessageDialog(null,"Fields cannot be left empty!!!"); 
    				    }
    		    	 else{
    		    		 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    		    		 con=DriverManager.getConnection("jdbc:odbc:SignUp_DSN");
    		    		 con.setAutoCommit(false);
    		    		 String firstname=textField.getText();
    		    		 String lastname=textField_1.getText();
    		    		 String email_id=textField_2.getText();
    		    		 String country=textField_5.getText();
    		    		 String state=textField_6.getText();
    		    	     String ph_no=textField_7.getText();
    		    		 char[] password=passwordField.getPassword();
    		    		 char[] retype_password=passwordField_1.getPassword();
    		    		 String sql="insert into Sign_Up(Firstname, Lastname, Email_id, Password, " +
    		    		 		"Retype_Password, Country, State, Phone_no)values(?,?,?,?,?,?,?,?)";
    		    		 ps=con.prepareStatement(sql);
    		    			 ps.setString(1, firstname);
    		    			 ps.setString(2, lastname);
    		    			 ps.setString(3, email_id);
    		    			 ps.setString(6, country);
    		    			 ps.setString(7, state);
    		    			 ps.setString(8,ph_no);
    		    			 ps.setString(4, new String(password));
    			    	     ps.setString(5, new String(retype_password) ); 
    			    	     ps.executeUpdate();
    			    		 JOptionPane.showMessageDialog(null, "Data is successfully inserted into database");
     
     
    	    			    	if(!(Arrays.equals(password, retype_password))){
    	    			    			 JOptionPane.showMessageDialog(null,"Passwords are not matching.Enter again!!!"); }
     
    	    			    	if(password.length<8 || retype_password.length<8){
    	   		    			 JOptionPane.showMessageDialog(null,"Password should be more than 8 characters!!!"); }
     
    			    		// while(rs.next()){ }
    		    		con.close(); 
    		    		ps.close();
    		    		 }
    		}catch(Exception ex){
     
    						String str=ex.toString();
    						JOptionPane.showMessageDialog(null,str);
    		        }
    			}
    	});


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,135
    My Mood
    Mellow
    Thanks
    187
    Thanked 659 Times in 646 Posts

    Default Re: java.SQL.Exception:"General Error"

    Thread moved.

    Welcome to the Forum! Thanks for taking the time to learn to post code correctly, and if you haven't already, please read this topic to see other useful info for newcomers.

    Posting the entire text of the error message/strack trace often reveals helpful information that your shortened version eliminates.

Similar Threads

  1. Replies: 2
    Last Post: June 22nd, 2013, 10:30 AM
  2. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  3. Replies: 0
    Last Post: October 5th, 2012, 07:27 AM
  4. Replies: 3
    Last Post: December 7th, 2011, 01:03 AM
  5. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM

Tags for this Thread