Results 1 to 4 of 4
  1. #1
    fcciko is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Default getinng data from mssql server 2008

    hi all i m preparin a term project. i ve problem about gettin data from sql server 2008. i can add entry to my database table. when i want to get that entry back i cant get arrival_city and arrival_time information. other informations shown. i m puttin my whole 3 classes can any one tell my error.
    Java Code:
    public class Client {
    	
    	private String name;
    	private String surname;
    	private String id_no;
    	private Object airline;
    	private String flight_no;
    	private String departure_date;
    	private Object departure_city;
    	private Object arrival_city;
    	private String departure_time;
    	private String arrival_time;
    	private String gate;
    	private String price;
    	
    	public Client()
    	{
    		
    	}
    	
    	// constructor begin
    	public Client(String isim, String soyisim, String kimlik_no, Object havayolu, String ucusno, String kalkisgunu, Object kalkissehri, Object varissehri, String kalkissaati, String varissaati, String kapi, String ucret) 
    	{
    		setname(isim);
    		setsurname(soyisim);
    		setid_no(kimlik_no);
    		setairline(havayolu);
    		setflight_no(ucusno);
    		setdeparture_date(kalkisgunu);
    		setdeparture_city(kalkissehri);
    		setarrival_city(varissehri);
    		setdeparture_time(kalkissaati);
    		setarrival_city(varissaati);
    		setgate(kapi);
    		setprice(ucret);
    	} // constructor end
     
    	public void setname(String isim) {
    		name=isim;
    		
    	}
    	
    	public String getname(){
    		return name;
    	}
     
    	public void setsurname(String soyisim) {
    		surname=soyisim;
    		
    	}
     
    	public String getsurname(){
    		return surname;
    	}
     
    	public void setid_no(String kimlik_no) {
    		id_no=kimlik_no;
    		
    	}
     
    	public String getid_no(){
    		return id_no;
    	}
     
     
    	public void setairline(Object havayolu) {
    		airline=havayolu;
    		
    	}
     
    	public Object getairline(){
    		return airline;
    	}
     
     
    	public void setflight_no(String ucusno) {
    		flight_no=ucusno;
    		
    	}
    	
    	public String getflight_no(){
    		return flight_no;
    	}
     
     
     
    	public void setdeparture_date(String kalkisgunu) {
    		departure_date=kalkisgunu;
    		
    	}
    	
    	public String getdeparture_date(){
    		return departure_date;
    	}
     
     
     
    	public void setdeparture_city(Object kalkissehri) {
    		departure_city=kalkissehri;
    		
    	}
    	
    	public Object getdeparture_city(){
    		return departure_city;
    	}
     
     
    	public void setarrival_city(Object varissehri) {
    		arrival_city=varissehri;
    		
    	}
    	
    	public Object getarrival_city(){
    		return arrival_city;
    	}
    	
    	
    	
    	public void setdeparture_time(String kalkissaati) {
    		departure_time=kalkissaati;
    		
    	}
    	
    	public String getdeparture_time(){
    		return departure_time;
    	}
    	
    	public void setarrival_time(String varissaati) {
    		departure_time=varissaati;
    		
    	}
     
    	public String getarrival_time() {
    		
    		return arrival_time;
    	}
     
    	public void setgate(String kapi) {
    		gate=kapi;
    		
    	}
    	
    	public String getgate(){
    		return gate;
    	}
     
     
    	public void setprice(String ucret) {
    		price=ucret;
    		
    	}
    	
    	public String getprice(){
    		return price;
    	}
    	
    }
    Java Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.List;
    import java.util.ArrayList;
     
    public class ClientQuery {    // class begin
    	
    	private static final String URL ="jdbc:sqlserver://localhost;databaseName=ticket_data;integratedSecurity=true";
    	
    	private Connection connection = null;
    	private PreparedStatement selectAllClient = null;
    	private PreparedStatement selectClientbyId_no = null;
    	private PreparedStatement insertNewClient = null;
    	
    	// person query constructor begin
    	
    	public ClientQuery (){
    		
    		try {
    			connection = DriverManager.getConnection( URL );
    			selectAllClient = connection.prepareStatement("SELECT * FROM Ticket");
    			selectClientbyId_no = connection.prepareStatement("SELECT * FROM Ticket WHERE id_no = ?");
    			insertNewClient = connection.prepareStatement("INSERT INTO Ticket "+
    			"(name,surname,id_no,airline,flight_no,departure_date,departure_city,arrival_city,departure_time,arrival_time,gate,price)" +
    			"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    		} // end try
    		catch (SQLException sqlException)
    		{
    			sqlException.printStackTrace();
    			System.exit(1);
    			
    		} // end catch
    		
    	}  // person query constructor end
    	
    	// select all client in database
    	public List <Client> getAllClient()
    	{
    		List<Client> results = null;
    		ResultSet resultSet = null;
    		
    		try 
    		{
    			resultSet = selectAllClient.executeQuery();
    			results = new ArrayList<Client>();
    			
    			while (resultSet.next())
    			{
    				
    				results.add(new Client(
    						    resultSet.getString("name"),
    						    resultSet.getString("surname"),
    						    resultSet.getString("id_no"),
    						    resultSet.getObject("airline"),
    						    resultSet.getString("flight_no"),
    						    resultSet.getString("departure_date"),
    						    resultSet.getObject("departure_city"),
    						    resultSet.getObject("arrival_city"),
    						    resultSet.getString("departure_time"),
    						    resultSet.getString("arrival_time"),
    						    resultSet.getString("gate"),
    						    resultSet.getString("price")));
    			}   // end while
    			
    		}  // end try
    		
    		catch (SQLException sqlException )
    		{
    			sqlException.printStackTrace();
    		}  // end catch
    		
    		finally
    		{
    			try{
    				resultSet.close();
    			} // end try
    			
    			catch (SQLException sqlException)
    			{
    				sqlException.printStackTrace();
    				close();
    			}  // end catch
    		}  //end finally
    		
    		return results;
    	} // end of get all client method
    	
    	// select Client by Airline
    	
    	public List <Client> getClientbyId_no(String name )
    	{
    		List<Client> results = null;
    		ResultSet resultSet = null;
    		
    		try 
    		{
                 selectClientbyId_no.setString(1, name);  
                 resultSet = selectClientbyId_no.executeQuery();
                 results = new ArrayList<Client>();
                 
                 while (resultSet.next())
     			{
     				
     				results.add(new Client(
     						    resultSet.getString("name"),
     						    resultSet.getString("surname"),
     						    resultSet.getString("id_no"),
     						    resultSet.getObject("airline"),
     						    resultSet.getString("flight_no"),
     						    resultSet.getString("departure_date"),
     						    resultSet.getObject("departure_city"),
     						    resultSet.getObject("arrival_city"),
     						    resultSet.getString("departure_time"),
     						    resultSet.getString("arrival_time"),
     						    resultSet.getString("gate"),
     						    resultSet.getString("price")));
     			}   // end while
    		
    	    } // end try
    		
    		catch (SQLException sqlException)
    		{
    			sqlException.printStackTrace();
    		}  // end catch
    		
    		finally
    		{
    			try{
    				resultSet.close();
    			} // end try
    			
    			catch (SQLException sqlException)
    			{
    				sqlException.printStackTrace();
    				close();
    			}  // end catch
    		}  //end finally
    		
    		return results;	
    	}    // end of select by airline method
    	
    	public int addClient(String name, String surname, String id_no, Object airline, String flight_no, String departure_date, Object departure_city, Object arrival_city, String departure_time, String arrival_time, String gate, String price)	
    	{
    		int result = 0;
    		try 
    		{
    			
    		insertNewClient.setString(1, name);
    		insertNewClient.setString(2, surname);
    		insertNewClient.setString(3, id_no);
    		insertNewClient.setObject(4, airline);
    		insertNewClient.setString(5, flight_no);
    		insertNewClient.setString(6, departure_date);
    		insertNewClient.setObject(7, departure_city);
    		insertNewClient.setObject(8, arrival_city);
    		insertNewClient.setString(9, departure_time);
    		insertNewClient.setString(10, arrival_time);
    		insertNewClient.setString(11, gate);
    		insertNewClient.setString(12, price);
    		
    		result = insertNewClient.executeUpdate();
    		}  // end try
    		
    		catch (SQLException sqlException)
    		{
    			sqlException.printStackTrace();
    			close();
    		}  // end catch
    		
    		return result;
    				
    	} // end of add Client method
    	
    	public void close ()
    	{
    		try
    		{
    			connection.close();
    			
    		}  // end try
    		
    		catch (SQLException sqlException)
    		{
    			sqlException.printStackTrace();
    		}  // end catch
    		
    	}  // end close method
    		
    } // class end
    Java Code:
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.List;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
     
    public class TicketSale extends JFrame{
    	
    	private Client currentEntry;
    	private ClientQuery clientQuery;
    	private List <Client> results;
    	private int numberOfEntries = 0;
    	private int currentEntryIndex;
    	
    	private JButton browseButton;
    	private JLabel  nameLabel;
    	private JTextField nameTextField;
    	private JLabel  surnameLabel;
    	private JTextField surnameTextField;
    	private JLabel id_noLabel;
    	private JTextField id_noTexField;
    	private String [] airline = {"THY", "KLM", "LUFTHANSA", "AIR FRANCE"};
    	private JLabel  airlineLabel;
    	private JComboBox airlineComboBox;
    	private JLabel  flight_noLabel;
    	private JTextField flight_noTextField;
    	private JLabel  departure_dateLabel;
    	private JTextField departure_dateTextField;
    	private String[] departure_city = {"İSTANBUL", "ANKARA" };
    	private JLabel  departure_cityLabel;
    	private JComboBox departure_cityComboBox;
    	private String[] arrival_city = {"LONDON", "PARIS", "MILANO", "MADRID", "BARCELONA", "MUNICH", "BERLIN", "ZURICH", "LIZBON" };
    	private JLabel  arrival_cityLabel;
    	private JComboBox arrival_cityComboBox;
    	private JLabel  departure_timeLabel;
    	private JTextField departure_timeTextField;
    	private JLabel  arrival_timeLabel;
    	private JTextField arrival_timeTextField;
    	private JLabel  gateLabel;
    	private JTextField gateTextField;
    	private JLabel  priceLabel;
    	private JTextField priceTextField;
    	private JButton nextButton;
    	private JLabel ofLabel;
    	private JTextField indexTextField;
    	private JTextField maxTextField;
    	private JButton previousButton;
    	private JButton queryButton;
    	private JLabel queryLabel;
    	private JPanel queryPanel;
    	private JPanel navigatePanel;
    	private JPanel displayPanel;
    	private JTextField queryTextField;
    	private JButton insertButton;
    	
    	public TicketSale()  // non-argument constructor
    	{
    		super("Ticket Sale");
    		
    		// establish database connection  and set up prepared statements
    		clientQuery = new ClientQuery();
    		
    		// create GUI
    		navigatePanel = new JPanel();
    		previousButton = new JButton();
    		indexTextField = new JTextField(2);
    		ofLabel = new JLabel();
    		maxTextField = new JTextField(2);
    		nextButton = new JButton();
    		displayPanel = new JPanel();
    		nameLabel = new JLabel();
    		nameTextField = new JTextField(10);
    		surnameLabel = new JLabel();
    		surnameTextField = new JTextField(10);
    		id_noLabel = new JLabel();
    		id_noTexField = new JTextField(11);
    		airlineLabel = new JLabel();
    		airlineComboBox = new JComboBox(airline);
    		flight_noLabel = new JLabel();
    		flight_noTextField = new JTextField(10);
    		departure_dateLabel = new JLabel();
    		departure_dateTextField = new JTextField(10);
    		departure_cityLabel = new JLabel();
    		departure_cityComboBox = new JComboBox(departure_city);
    		arrival_cityLabel = new JLabel();
    		arrival_cityComboBox = new JComboBox(arrival_city);
    		departure_timeLabel = new JLabel();
    		departure_timeTextField = new JTextField(10);
    		arrival_timeLabel = new JLabel();
    		arrival_timeTextField = new JTextField(10);
    		gateLabel = new JLabel();
    		gateTextField = new JTextField(10);
    		priceLabel = new JLabel();
    		priceTextField = new JTextField(10);
    		queryPanel = new JPanel();
    		queryLabel = new JLabel();
    		queryTextField = new JTextField(10);
    		queryButton = new JButton();
    		browseButton = new JButton();
    		queryButton = new JButton();
    		insertButton = new JButton();
    		
    		setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
    		setSize(1280,600);
    		setResizable(false);
    		
    		navigatePanel.setLayout(
    						new BoxLayout (navigatePanel, BoxLayout.X_AXIS));
    		
    		previousButton.setText("Previous");
    		previousButton.setEnabled(false);
    		previousButton.addActionListener(
    				new ActionListener()
    				{
    					public void actionPerformed (ActionEvent evt)
    					{
    						previousButtonActionPerformed(evt);
    					} // end method action performed
    					
    				}			
    		);  // end call to add ActionListener
    		
    		navigatePanel.add(previousButton);
    		navigatePanel.add(Box.createHorizontalStrut(10));
    		
    		indexTextField.setHorizontalAlignment(JTextField.CENTER);
    		indexTextField.addActionListener(
    		
    				new ActionListener() {
    					public void actionPerformed(ActionEvent evt) {
    						indexTextFieldActionPerformed(evt);
    						
    					}  // end method action performed
    				}
    				
    		); // end call to add ActionListener
    navigatePanel.add(indexTextField);
    		navigatePanel.add(Box.createHorizontalStrut(10));
    		
    		ofLabel.setText("of");
    		navigatePanel.add(ofLabel);
    		navigatePanel.add(Box.createHorizontalStrut(10));
    		
    		maxTextField.setHorizontalAlignment(JTextField.CENTER);
    		maxTextField.setEditable(false);
    		navigatePanel.add(maxTextField);
    		navigatePanel.add(Box.createHorizontalStrut(10));
    		
    		nextButton.setText("Next");
    		nextButton.setEnabled(false);
    		nextButton.addActionListener(
    				
    				new ActionListener() {				
    					public void actionPerformed(ActionEvent evt) {
    						nextButtonActionPerformed(evt);
    						
    					} // end method ActionPerformed
    				}
    				
    		); // end call to add ActionListener
    navigatePanel.add(nextButton);
    		add(navigatePanel);
    		displayPanel.setLayout(new GridLayout(4, 4));
    		
    		nameLabel.setText("NAME:");
    		displayPanel.add(nameLabel);
    		displayPanel.add(nameTextField);
    		
    		
    		surnameLabel.setText("SURNAME:");
    		displayPanel.add(surnameLabel);
    		displayPanel.add(surnameTextField);
    		
    		id_noLabel.setText("Id_No:");
    		displayPanel.add(id_noLabel);
    		displayPanel.add(id_noTexField);
    		
    		airlineLabel.setText("AIRLINE:");
    		displayPanel.add(airlineLabel);
    		displayPanel.add(airlineComboBox);
    		
    		flight_noLabel.setText("FLIGHT NO:");
    		displayPanel.add(flight_noLabel);
    		displayPanel.add(flight_noTextField);
    		
    		departure_dateLabel.setText("DEPARTURE DATE:");
    		displayPanel.add(departure_dateLabel);
    		displayPanel.add(departure_dateTextField);
    		
    		departure_cityLabel.setText("DEPARTURE CITY:");
    		displayPanel.add(departure_cityLabel);
    		displayPanel.add(departure_cityComboBox);
    		
    		arrival_cityLabel.setText("ARRIVAL CITY:");
    		displayPanel.add(arrival_cityLabel);
    		displayPanel.add(arrival_cityComboBox);
    		
    		departure_timeLabel.setText("DEPARTURE TIME:");
    		displayPanel.add(departure_timeLabel);
    		displayPanel.add(departure_timeTextField);
    		
    		arrival_timeLabel.setText("ARRIVAL TIME:");
    		displayPanel.add(arrival_timeLabel);
    		displayPanel.add(arrival_timeTextField);
    		
    		gateLabel.setText("GATE:");
    		displayPanel.add(gateLabel);
    		displayPanel.add(gateTextField);
    		
    		priceLabel.setText("PRICE:");
    		displayPanel.add(priceLabel);
    		displayPanel.add(priceTextField);
    		add(displayPanel);
    		
    		queryPanel.setLayout(new BoxLayout(queryPanel, BoxLayout.X_AXIS));
    		queryPanel.setBorder(BorderFactory.createTitledBorder("Find An Entry By Identity Number"));
    		queryLabel.setText("ID_NO:");
    		queryPanel.add(Box.createHorizontalStrut(5));
    		queryPanel.add(queryLabel);
    		queryPanel.add(Box.createHorizontalStrut(10));
    		queryPanel.add(queryTextField);
    		queryPanel.add(Box.createHorizontalStrut(10));
    		
    		queryButton.setText("Find");
    		queryButton.addActionListener(
    		new ActionListener() {
    			public void actionPerformed(ActionEvent evt) {
    				queryButtonActionPerformed(evt);
    				
    			}  // end method action performed
    		}		
    		
    		);  //  end call to add ActionListener
    		
    		queryPanel.add(queryButton);
    		queryPanel.add(Box.createHorizontalStrut(5));
    		add(queryPanel);
    		
    		browseButton.setText("Browse All Enries");
    		browseButton.addActionListener(
    			new ActionListener() {				
    				public void actionPerformed(ActionEvent evt) {
    					queryButtonActionPerformed(evt);	
    					
    				} // end method to add action performed
    			}	
    		);  // end call to add ActionListener
    		
    		add (browseButton);
    		
    	    insertButton.setText("Insert New Entry");
    	    insertButton.addActionListener(
    	           new ActionListener() {	
    				public void actionPerformed(ActionEvent evt) {
    					insertButtonActionPerformed(evt);
    					
    				} // end method to add action performed
    			}	
    	    );  // end call to add ActionListener 
    		
    	    add(insertButton);
    	    
    	    addWindowListener(
    	         new WindowAdapter() {
    	    	public void windowClosing(WindowEvent evt)
    	    	{
    	    		clientQuery.close();  // close database connection
    	    		System.exit(0);
    	    		
    	    	}  // end method window Closing	    
    	       }
    	    ); //end call to addWindowListener
    		setVisible(true);
    	} // end no-argument constructor
    private void previousButtonActionPerformed(ActionEvent evt)
    	{
    		currentEntryIndex--;
    		
    		if (currentEntryIndex < 0)
    			currentEntryIndex =numberOfEntries -1;
    		indexTextField.setText("" + (currentEntryIndex + 1));
    		indexTextFieldActionPerformed(evt);
    		
    	} // end method previous button Action Performed
    	
    	private void nextButtonActionPerformed(ActionEvent evt)
    	{
    		currentEntryIndex++;
    		
    		if (currentEntryIndex >= numberOfEntries)
    			
    		currentEntryIndex = 0;
    		indexTextField.setText("" + (currentEntryIndex + 1));
    		indexTextFieldActionPerformed(evt);
    		
    	} // end method next button Action Performed
    		
    	// getting an entry when click on find client by id_no
    	private void queryButtonActionPerformed (ActionEvent evt)
    	{
    		results = clientQuery.getClientbyId_no(queryTextField.getText());
    		numberOfEntries = results.size();
    		
    		if (numberOfEntries != 0)
    			
    		{
    			currentEntryIndex =0;
    			currentEntry = results.get(currentEntryIndex);
    			nameTextField.setText(currentEntry.getname());
    			surnameTextField.setText(currentEntry.getsurname());
    			id_noTexField.setText(currentEntry.getid_no());
    			airlineComboBox.setSelectedItem(currentEntry.getairline());
    			flight_noTextField.setText(currentEntry.getflight_no());
    			departure_dateTextField.setText(currentEntry.getdeparture_date());
    			departure_cityComboBox.setSelectedItem(currentEntry.getdeparture_city());
    			arrival_cityComboBox.setSelectedItem(currentEntry.getarrival_city());
    			departure_timeTextField.setText(currentEntry.getdeparture_time());
    			arrival_timeTextField.setText(currentEntry.getarrival_time());
    			gateTextField.setText(currentEntry.getgate());
    			priceTextField.setText(currentEntry.getprice());
    			maxTextField.setText("" + numberOfEntries);
    			indexTextField.setText("" + (currentEntryIndex + 1));
    			nextButton.setEnabled(true);
    			previousButton.setEnabled(true);
    		} // end if
    		
    		else
    			browseButtonActionPerformed(evt);
    		
    	} // end method queryButton AcitonPerformed
    	
    	private void indexTextFieldActionPerformed(ActionEvent evt)
    	{
    		currentEntryIndex = (Integer.parseInt(indexTextField.getText()) - 1);
    		if (numberOfEntries !=0 && currentEntryIndex < numberOfEntries )
    		{
    			currentEntry = results.get(currentEntryIndex);
    			nameTextField.setText(currentEntry.getname());
    			surnameTextField.setText(currentEntry.getsurname());
    			id_noTexField.setText(currentEntry.getid_no());
    			airlineComboBox.setSelectedItem(currentEntry.getairline());
    			flight_noTextField.setText(currentEntry.getflight_no());
    			departure_dateTextField.setText(currentEntry.getdeparture_date());
    			departure_cityComboBox.setSelectedItem(currentEntry.getdeparture_city());
    			arrival_cityComboBox.setSelectedItem(currentEntry.getarrival_city());
    			departure_timeTextField.setText(currentEntry.getdeparture_time());
    			arrival_timeTextField.setText(currentEntry.getarrival_time());
    			gateTextField.setText(currentEntry.getgate());
    			priceTextField.setText(currentEntry.getprice());
    			maxTextField.setText("" + numberOfEntries);
    			indexTextField.setText("" + (currentEntryIndex + 1));
    		}  // end if
    		
    	}  // end method indexTextField ActionPerformed
    	
    	// getting all entries when browse button is clicked 
    	private void browseButtonActionPerformed(ActionEvent evt)
    	{
    		try
    		{
    			results = clientQuery.getAllClient();
    			numberOfEntries = results.size();
    			if (numberOfEntries != 0 )
    			{
    				currentEntryIndex =0;
    				currentEntry = results.get(currentEntryIndex);
    				nameTextField.setText(currentEntry.getname());
    				surnameTextField.setText(currentEntry.getsurname());
    				id_noTexField.setText(currentEntry.getid_no());
    				airlineComboBox.setSelectedItem(currentEntry.getairline());
    				flight_noTextField.setText(currentEntry.getflight_no());
    				departure_dateTextField.setText(currentEntry.getdeparture_date());
    				departure_cityComboBox.setSelectedItem(currentEntry.getdeparture_city());
    				arrival_cityComboBox.setSelectedItem(currentEntry.getarrival_city());
    				departure_timeTextField.setText(currentEntry.getdeparture_time());
    				arrival_timeTextField.setText(currentEntry.getarrival_time());
    				gateTextField.setText(currentEntry.getgate());
    				priceTextField.setText(currentEntry.getprice());
    				maxTextField.setText("" + numberOfEntries);
    				indexTextField.setText("" + (currentEntryIndex + 1));
    				nextButton.setEnabled(true);
    				previousButton.setEnabled(true);
    			} // end if
    				
    		} // end try
    		
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		} // end catch
    		
    	} // end method browseButton ActionPerformed
    	
    	// insert an entry when insertButton clicked
    	private void insertButtonActionPerformed (ActionEvent evt)
    	{
    		int result = clientQuery.addClient(nameTextField.getText(),
    				surnameTextField.getText(), id_noTexField.getText(), airlineComboBox.getSelectedItem(), flight_noTextField.getText(),
    				departure_dateTextField.getText(), departure_cityComboBox.getSelectedItem(), arrival_cityComboBox.getSelectedItem(),
    				departure_timeTextField.getText(), arrival_timeTextField.getText(), gateTextField.getText(), priceTextField.getText());
    		if (result == 1)
    			JOptionPane.showMessageDialog(this, "Client Added", "Client Added", JOptionPane.PLAIN_MESSAGE);
    		else
    			JOptionPane.showMessageDialog(this, "Client Not Added", "ERROR", JOptionPane.PLAIN_MESSAGE);
    		
    		browseButtonActionPerformed(evt);
    	} // end method insertButton ActionPerformed
     
    	public static void main(String[] args) {
    		new TicketSale();
    	} // end method main
     
    }  // end class TicketSale
    :confused:

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    That's far too much to read, by the way.

    However (and I've seen this code before), why are you doing set and getObject()?
    Are those things actually objects in the table, or are they Strings?

  3. #3
    fcciko is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Default

    i made combobox for airline departure_city and arrival_city then eclipse give error that cant use string if i use combobox then i nedd to change them in to object. i made arrays for 3 combobox.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    You're flailing then.
    You can get the string value out of the combo box...there is no reason to be using setObject() (or getObject()). You know that it's a String so cast it to a String before calling the add/whatever method.

    And test your db stuff in isolation, because that is far too much code up there for someone to look through.

Similar Threads

  1. Replies: 0
    Last Post: 04-05-2009, 01:22 PM
  2. Connecting to SQL Server 2008 DB
    By Lyle in forum Eclipse
    Replies: 1
    Last Post: 02-22-2009, 04:26 PM
  3. Problem conecting to SQL Server 2008
    By Ludson27 in forum JDBC
    Replies: 1
    Last Post: 02-20-2009, 11:16 AM
  4. Not able to delete MSSql database table entries
    By wickedrahul9 in forum Advanced Java
    Replies: 3
    Last Post: 10-17-2008, 12:14 PM
  5. Replies: 0
    Last Post: 09-01-2008, 11:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •