1 Replies - 2154 Views - Last Post: 25 November 2010 - 03:30 PM Rate Topic: -----

#1 nicagal2000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-November 10

Inserting into access database from JavaGUI

Posted 25 November 2010 - 02:14 PM

I am trying to insert records into an access database from a GUI and I am getting the error message that I used to handled the exception.May I get help please as nothing is going to my database and there is a running connection between the client and the server built.

public void InsertCustomer(CustomerClass obj)
{
	SQLConnect();
	
	try
	{
		stat=con.createStatement();
		
		String query=("INSERT INTO Customer(Fname,Lname,Address1,Address2,Parish,POffice,Telephone#,Status) VALUES('"+obj.getFName()+"','"+obj.getLName()+"','"+obj.getAddress1()+"','"+obj.getAddress2()+"','"+obj.getParish()+"','"+obj.getPO()+"','"+obj.getTelephone()+"',"+obj.getStatus()+"')");
		System.out.println(query);
						  
		stat.executeQuery(query);

	
		}//closing try
	
	catch(Exception ex)
	{
		JOptionPane.showMessageDialog(null,"Sorry, there was a problem with inserting new Customer, check sql connection",null,JOptionPane.ERROR_MESSAGE);
		
	}//closing catch block


This post has been edited by macosxnerd101: 25 November 2010 - 03:21 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Inserting into access database from JavaGUI

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10193
  • View blog
  • Posts: 37,640
  • Joined: 27-December 08

Re: Inserting into access database from JavaGUI

Posted 25 November 2010 - 03:30 PM

Can you print out the Exception to your console and post the Stack Trace?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1