Accessing tables from java

I am creating an inventory system. I have used Java for front-end where i have created forms which display the vendor table, customer table, item table, order table, invoice tbl etc.
I have created class files for each form that im displaying. i have also made connection to the oracle dbs succesfully. i can access data from the dbs.
but my problem is,
1)
for instance i have created a vendor_master table in oracle with certain constraints like vendor_number can contain only 5 varchar2 characters ,
eg.
create table vendor_master
(v_no varchar2(5) constraint v_no_pk primary key,
v_name varchar2(25),
v_add varchar2(15),
city varchar2(15),
st varchar2(15),
zip number(10),
tel number(11),
fax number(11));
now when i want 2 insert any row in the table i should be able 2 insert only "certain" characters of "certain" length depending on the constraints i have set. how do i do tht? coz java does not allow me 2 set the max chars like VB in the properties column
i have my vendor Master class file here:
code:--------------------------------------------------------------------------------
package mainpage;
import java.io.*;
import java.io.Serializable;
import java.awt.*;
import java.awt.event.*;
import java.lang.String.*;
import javax.swing.*;
import javax.swing.JPanel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.Vector;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.OracleResultSet;
import java.sql.PreparedStatement;
public class VendorMaster extends JPanel implements java.io.Serializable
JFrame venMastFrame = new JFrame("Vendor Master");
JLabel vennolbl = new JLabel();
JLabel venNamelbl = new JLabel();
JLabel venAdd = new JLabel();
JTextField venAddtxt = new JTextField();
JTextField venNotxt = new JTextField();
JTextField venNmtxt = new JTextField();
JLabel venCitylbl = new JLabel();
JTextField venCitytxt = new JTextField();
JLabel venStlbl = new JLabel();
JTextField venSttxt = new JTextField();
JLabel venZiplbl = new JLabel();
JTextField venZiptxt = new JTextField();
JLabel venTellbl = new JLabel();
JTextField venTeltxt = new JTextField();
JLabel venFaxlbl = new JLabel();
JTextField venFaxtxt = new JTextField();
JButton vPrevbtn = new JButton();
JButton vNxtbtn = new JButton();
JButton vExitbtn = new JButton();
JButton vNewbtn = new JButton();
JButton vDelbtn = new JButton();
JButton vUpdtbtn = new JButton();
JButton vSavebtn = new JButton();
int currentIndex = 0;
int totalRecords = 0;
private Vector vendorMasterRecords = new Vector();
public VendorMaster()
venMastFrame.setSize(850,760);
venMastFrame.setVisible(true);
//venMastFrame.show();
try
jbInit();
} catch (Exception e)
e.printStackTrace();
} // end of constructor
private void jbInit() throws Exception
Connection myConnection = DataManager.createConnection();
vendorMasterRecords = loadVendorMasterRecords(myConnection);
VendorMasterBean vmBean = null;
venMastFrame.getContentPane().setLayout(null);
if(vendorMasterRecords != null)
{                 vmBean = (VendorMasterBean)vendorMasterRecords.elementAt(0);
totalRecords = vendorMasterRecords.size();
currentIndex = 0;
if(vmBean == null)
vmBean = new VendorMasterBean();
venNamelbl.setText("Vendor Name:");
venNamelbl.setBounds(new Rectangle(22, 87, 89, 23));
venNmtxt.setBounds(new Rectangle(153, 81, 224, 22));
venNmtxt.setEnabled(false);
venNmtxt.setText(vmBean.getVendorName());
venAdd.setText("Address:");
venAdd.setBounds(new Rectangle(25, 130, 113, 31));
venAddtxt.setBounds(new Rectangle(152, 126, 201, 22));
venAddtxt.setEnabled(false);
venAddtxt.setText(vmBean.getAddress());
vennolbl.setText("Vendor No:");
vennolbl.setBounds(new Rectangle(23, 41, 73, 22));
venNotxt.setBounds(new Rectangle(155, 38, 108, 22));
venNotxt.setEnabled(false);
venNotxt.setText(vmBean.getVendorNumber());
venCitylbl.setText("City:");
venCitylbl.setBounds(new Rectangle(25, 175, 61, 29));
venCitytxt.setBounds(new Rectangle(153, 172, 156, 24));
venCitytxt.setEnabled(false);
venCitytxt.setText(vmBean.getCity());
venStlbl.setText("State:");
venStlbl.setBounds(new Rectangle(25, 225, 64, 32));
venSttxt.setBounds(new Rectangle(152, 223, 158, 24));
venSttxt.setEnabled(false);
venSttxt.setText(vmBean.getState());
venZiplbl.setText("Zip:");
venZiplbl.setBounds(new Rectangle(24, 275, 58, 24));
venZiptxt.setBounds(new Rectangle(150, 272, 108, 24));
venZiptxt.setEnabled(false);
venZiptxt.setText(vmBean.getZipcode());
venTellbl.setText("Telephone No:");
venTellbl.setBounds(new Rectangle(25, 323, 106, 26));
venTeltxt.setBounds(new Rectangle(149, 326, 108, 26));
venTeltxt.setEnabled(false);
venTeltxt.setText(vmBean.getTelephone());
venFaxlbl.setText("Fax No:");
venFaxlbl.setBounds(new Rectangle(27, 375, 97, 26));
venFaxtxt.setBounds(new Rectangle(149, 375, 107, 26));
venFaxtxt.setEnabled(false);
venFaxtxt.setText(vmBean.getFax());
/* code for buttons */
vExitbtn.setBounds(new Rectangle(681, 457, 111, 29));
vExitbtn.setText("EXIT");
vExitbtn.addKeyListener(new VendorMaster_vExitbtn_keyAdapter(this));
vExitbtn.addActionListener(new VendorMaster_vExitbtn_actionAdapter(this));
vPrevbtn.setText("PREVIOUS");
vPrevbtn.addKeyListener(new VendorMaster_vPrevbtn_keyAdapter(this));
vPrevbtn.addActionListener(new VendorMaster_vPrevbtn_actionAdapter(this));
vPrevbtn.setBounds(new Rectangle(14, 457, 110, 29));
vPrevbtn.setEnabled(false);
vNxtbtn.setText("NEXT");
vNxtbtn.addKeyListener(new VendorMaster_vNxtbtn_keyAdapter(this));
vNxtbtn.addActionListener(new VendorMaster_vNxtbtn_actionAdapter(this));
vNxtbtn.setBounds(new Rectangle(124, 457, 111, 29));
vNewbtn.setText("NEW");
vNewbtn.setBounds(new Rectangle(235, 457, 111, 29));
vNewbtn.setActionCommand("NEW");
vNewbtn.addActionListener(new VendorMaster_vNewbtn_actionAdapter(this));
vNewbtn.addKeyListener(new VendorMaster_vNewbtn_keyAdapter(this));
vDelbtn.setText("DELETE");
vDelbtn.setBounds(new Rectangle(346, 457, 111, 29));
vDelbtn.setHorizontalAlignment(SwingConstants.CENTER);
vDelbtn.addActionListener(new VendorMaster_vDelbtn_actionAdapter(this));
vDelbtn.addKeyListener(new VendorMaster_vDelbtn_keyAdapter(this));
vUpdtbtn.setText("UPDATE");
vUpdtbtn.addActionListener(new VendorMaster_vUpdtbtn_actionAdapter(this));
vUpdtbtn.setBounds(new Rectangle(457, 457, 113, 29));
vUpdtbtn.setMaximumSize(new Dimension(71, 25));
vUpdtbtn.setMinimumSize(new Dimension(71, 25));
vUpdtbtn.setPreferredSize(new Dimension(71, 25));
/* Add all the txtboxes, lbls and buttons to the frame */
vSavebtn.setBounds(new Rectangle(570, 457, 111, 29));
vSavebtn.setText("SAVE");
vSavebtn.addActionListener(new VendorMaster_vSavebtn_actionAdapter(this));
venMastFrame.getContentPane().add(vennolbl, null);
venMastFrame.getContentPane().add(venNotxt, null);
venMastFrame.getContentPane().add(venNamelbl, null);
venMastFrame.getContentPane().add(venNmtxt, null);
venMastFrame.getContentPane().add(venAdd, null);
venMastFrame.getContentPane().add(venAddtxt, null);
venMastFrame.getContentPane().add(venCitylbl, null);
venMastFrame.getContentPane().add(venCitytxt, null);
venMastFrame.getContentPane().add(venStlbl, null);
venMastFrame.getContentPane().add(venSttxt, null);
venMastFrame.getContentPane().add(venZiplbl, null);
venMastFrame.getContentPane().add(venZiptxt, null);
venMastFrame.getContentPane().add(venTellbl, null);
venMastFrame.getContentPane().add(venTeltxt, null);
venMastFrame.getContentPane().add(venFaxlbl, null);
venMastFrame.getContentPane().add(venFaxtxt, null);
venMastFrame.getContentPane().add(vPrevbtn, null);
venMastFrame.getContentPane().add(vNxtbtn, null);
venMastFrame.getContentPane().add(vNewbtn, null);
venMastFrame.getContentPane().add(vDelbtn, null);
venMastFrame.getContentPane().add(vUpdtbtn, null);
venMastFrame.getContentPane().add(vSavebtn, null);
venMastFrame.getContentPane().add(vExitbtn, null);
} // end of jbinit
public static void main(String[] args)
VendorMaster vendorMaster1 = new VendorMaster();
} //end of main
/* this is where the data will be retrieved from the dbs */
protected Vector loadVendorMasterRecords(Connection connection)
//Connection connection = null;
Vector masterRecords = new Vector();
// From database getting values
try
//connection = connectionManager.getConnection();
Statement stmt = connection.createStatement();
String queryall = "Select * from vendor_master order by v_no";
ResultSet rs = stmt.executeQuery(queryall);
while (rs.next())
String vendorNumber = rs.getString("v_no");
String vendorName = rs.getString("v_name");
String address = rs.getString("v_add");
String city = rs.getString("city");
String state = rs.getString("st");
String zipCode = rs.getString("zip");
String telephone = rs.getString("tel");
String fax = rs.getString("fax");
VendorMasterBean vendorMasterBean = new VendorMasterBean(vendorNumber,
vendorName,
address,
city,
state,
zipCode,
telephone,
fax);
/* data retrieved from the vendormasterbean is then inserted in vector*/
masterRecords.addElement(vendorMasterBean);
} // end of while
} catch (Exception e) // end of try & start of catch
e.printStackTrace();
} // end of catch
finally
if(connection != null)
DataManager.freeConnection(connection);
return masterRecords; /* the data stored in
masterRecords is passed 2 vendormasterRecords*/
} // finally ends here
} // end of loadvendorMasterrecords
/*example- when previous button is pressed then an event is triggered
captured by the key listener and then actionPerformed method is called
which in turn calls the getPreviousRecord*/
/* to insert records */
protected void addVendorMasterRecord(VendorMasterBean vmBean )
Connection connection = null;
Vector masterRecords = new Vector();
// first check whether all the textboxes are empty
// also check whether there is already a record
//existing with the same v_no
// From database getting values
try
connection = DataManager.createConnection();
PreparedStatement newRecord = connection.prepareStatement("insert into vendor_master values(?,?,?,?,?,?,?,?)");
newRecord.setString(1,vmBean.getVendorNumber());
newRecord.setString(2, vmBean.getVendorName());
newRecord.setString(3, vmBean.getAddress());
newRecord.setString(4, vmBean.getCity());
newRecord.setString(5, vmBean.getState());
newRecord.setString(6, vmBean.getZipcode());
newRecord.setString(7, vmBean.getTelephone());
newRecord.setString(8, vmBean.getFax());
newRecord.executeUpdate();
// Insert statement
// PreparedStatement pStmt = ....;
// The assign each value in the vmBean to the pStmt
// and finally execute the pStmt
} catch (Exception e) // end of try and begin of catch
e.printStackTrace();
} // end of catch
finally
if(connection != null)
DataManager.freeConnection(connection);
}// end of if
} // end of finally
} // end of addVendorMasterRecord
void vNewbtn_actionPerformed(ActionEvent e)
/* First empty all the textboxes */
venNotxt.setText(" ");
venNmtxt.setText(" ");
venAddtxt.setText(" ");
venCitytxt.setText(" ");
venSttxt.setText(" ");
venZiptxt.setText(" ");
venTeltxt.setText(" ");
venFaxtxt.setText(" ");
venNotxt.setEnabled(true);
venNmtxt.setEnabled(true);
venAddtxt.setEnabled(true);
venCitytxt.setEnabled(true);
venSttxt.setEnabled(true);
venZiptxt.setEnabled(true);
venTeltxt.setEnabled(true);
venFaxtxt.setEnabled(true);
vPrevbtn.setEnabled(false);
vNxtbtn.setEnabled(false);
void vNewbtn_keyPressed(KeyEvent e)
/* to delete records */
protected void removeVendorMasterRecord(VendorMasterBean vmBean )
Connection connection = null;
Vector masterRecords = new Vector();
// From database getting values
try
connection = DataManager.createConnection();
PreparedStatement deleteRecord = connection.prepareStatement("delete from vendor_master where v_no = ?");
deleteRecord.setString(1, vmBean.getVendorNumber());
deleteRecord.executeUpdate();
// Delete statement for where condition pass the vendor number as parameter
//"delete from vendor_master where v_no = ?"
//PreparedStatement pStmt = ....;
// The assign v_no in the vmBean to the pStmt
// and finally execute the pStmt
} catch (Exception e)
e.printStackTrace();
finally
// After executing this new record should be removed from the Vector of results.
// uncomment this
if(connection != null){
DataManager.freeConnection(connection);
} // end of finally
} // end of removeVendorMasterRecord
void vDelbtn_actionPerformed(ActionEvent e)
String vendorNumber = venNotxt.getText();
String vendorName = venNmtxt.getText();
String address = venAddtxt.getText();
String city = venCitytxt.getText();
String state = venSttxt.getText();
String zipCode = venZiptxt.getText();
String telephone = venTeltxt.getText();
String fax = venFaxtxt.getText();
VendorMasterBean vmBean = new VendorMasterBean(vendorNumber,vendorName, address, city, state, zipCode, telephone, fax);
removeVendorMasterRecord(vmBean);
void vDelbtn_keyPressed(KeyEvent e)
/* To get next record */
protected VendorMasterBean getNextRecord()
VendorMasterBean vmBean = new VendorMasterBean();
if(currentIndex < totalRecords)
vmBean =(VendorMasterBean)vendorMasterRecords.elementAt(++currentIndex);
if(currentIndex == (totalRecords-1) )
// reached last, so disable the Next button
vNxtbtn.setEnabled(false);
// enable the Previous
vPrevbtn.setEnabled(true);
} // end of if stmt
} // end of outer if stmt
return vmBean;
} // end of getnextrecord
void vNxtbtn_keyPressed(KeyEvent e)
void vNxtbtn_actionPerformed(ActionEvent e)
VendorMasterBean vmBean = getNextRecord();
venNotxt.setText(vmBean.getVendorNumber());
venNmtxt.setText(vmBean.getVendorName());
venAddtxt.setText(vmBean.getAddress());
venCitytxt.setText(vmBean.getCity());
venSttxt.setText(vmBean.getState());
venZiptxt.setText(vmBean.getZipcode());
venTeltxt.setText(vmBean.getTelephone());
venFaxtxt.setText(vmBean.getFax());
/* to get previous record */
protected VendorMasterBean getPreviousRecord()
VendorMasterBean vmBean = new VendorMasterBean();
if(currentIndex > 0)
vmBean =(VendorMasterBean)vendorMasterRecords.elementAt(--currentIndex);
if(currentIndex == 0)
// reached first so disable the Previous button
vPrevbtn.setEnabled(false);
// enable the Next
vNxtbtn.setEnabled(true);
} // end of inner if stmt
} // end of outer if stmt
return vmBean;
} // end of previousrecord
void vPrevbtn_actionPerformed(ActionEvent e)
VendorMasterBean vmBean = getPreviousRecord();
venNmtxt.setText(vmBean.getVendorName());
venAddtxt.setText(vmBean.getAddress());
venNotxt.setText(vmBean.getVendorNumber());
venCitytxt.setText(vmBean.getCity());
venSttxt.setText(vmBean.getState());
venZiptxt.setText(vmBean.getZipcode());
venTeltxt.setText(vmBean.getTelephone());
venFaxtxt.setText(vmBean.getFax());
void vPrevbtn_keyPressed(KeyEvent e)
void vUpdtbtn_actionPerformed(ActionEvent e)
/* when the update button is pressed , only the v_no is disabled
vPrevbtn.setEnabled(false);
vNxtbtn.setEnabled(false);
venNmtxt.setEnabled(true);
venAddtxt.setEnabled(true);
venCitytxt.setEnabled(true);
venSttxt.setEnabled(true);
venZiptxt.setEnabled(true);
venTeltxt.setEnabled(true);
venFaxtxt.setEnabled(true);
//then the user should press the save button
void vExitbtn_actionPerformed(ActionEvent e)
venMastFrame.setDefaultCloseOperation(venMastFrame.EXIT_ON_CLOSE);
void vExitbtn_keyPressed(KeyEvent e)
void vSavebtn_actionPerformed(ActionEvent e)
String vendorNumber = venNotxt.getText();
String vendorName = venNmtxt.getText();
String address = venAddtxt.getText();
String city = venCitytxt.getText();
String state = venSttxt.getText();
String zipCode = venZiptxt.getText();
String telephone = venTeltxt.getText();
String fax = venFaxtxt.getText();
VendorMasterBean vmBean = new VendorMasterBean(vendorNumber, vendorName,address, city, state, zipCode, telephone, fax);
addVendorMasterRecord(vmBean);
} // end of vSavebtn_actionPerformed
} // end of class vendormaster
//Adapter classes
class VendorMaster_vNxtbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vNxtbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vNxtbtn_actionPerformed(e);
class VendorMaster_vNxtbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vNxtbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vNxtbtn_keyPressed(e);
class VendorMaster_vPrevbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vPrevbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vPrevbtn_actionPerformed(e);
class VendorMaster_vPrevbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vPrevbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vPrevbtn_keyPressed(e);
class VendorMaster_vExitbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vExitbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vExitbtn_actionPerformed(e);
class VendorMaster_vExitbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vExitbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vExitbtn_keyPressed(e);
class VendorMaster_vNewbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vNewbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vNewbtn_actionPerformed(e);
class VendorMaster_vNewbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vNewbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vNewbtn_keyPressed(e);
class VendorMaster_vDelbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vDelbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vDelbtn_actionPerformed(e);
class VendorMaster_vDelbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vDelbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vDelbtn_keyPressed(e);
class VendorMaster_vUpdtbtn_actionAdapter implements java.awt.event.ActionListener {
VendorMaster adaptee;
VendorMaster_vUpdtbtn_actionAdapter(VendorMaster adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.vUpdtbtn_actionPerformed(e);
class VendorMaster_vSavebtn_actionAdapter implements java.awt.event.ActionListener {
VendorMaster adaptee;
VendorMaster_vSavebtn_actionAdapter(VendorMaster adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.vSavebtn_actionPerformed(e);
the following code is the vendorMasterBean class file- this file helps 2 assign data to the various textboxes.
code:--------------------------------------------------------------------------------
package mainpage;
public class VendorMasterBean
private String vendorNumber;
private String vendorName;
private String address;
private String city;
private String state;
private String zipcode;
private String telephone;
private String fax;
public int Mandatory_Value;
public VendorMasterBean()
} // end of constructor
public VendorMasterBean(String vendorNumber,String vendorName,String address,String city,String state,String zipcode,String telephone,String fax)
setVendorNumber(vendorNumber);
setVendorName(vendorName);
setAddress(address);
setCity(city);
setState(state);
setZipcode(zipcode);
setTelephone(telephone);
setFax(fax);
/* Set Method */
public void setVendorNumber(String vendorNumber)
try
if ( (vendorNumber == null) || (vendorNumber.length() <= 0) || (vendorNumber.length() > 5))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Vendor Number");
} // end of if stmt
else {
this.vendorNumber = vendorNumber;
} // end of else
catch(Exception e)
e.printStackTrace();
} // end of setVendorNumber
public void setVendorName(String vendorName)
try
if((vendorName == null) || (vendorName.length() <=0 && vendorName.length() > 25))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Vendor Name");
}// end of if
else
this.vendorName = vendorName;
} // end of else
} // end of try
catch(Exception e)
e.printStackTrace();
}// end of set method
public void setAddress(String address)
try
if((address == null) ||(address.length() <=0 && address.length()>15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Address");
else
this.address = address;
catch(Exception e)
e.printStackTrace();
public void setCity(String city)
try
if((city == null) ||(city.length()<=0 && city.length() > 15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"City");
else
this.city = city;
catch(Exception e)
e.printStackTrace();
public void setState(String state)
try
if((state == null) || (state.length()<=0 && state.length() >15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"State");
else
this.state = state;
catch(Exception e)
e.printStackTrace();
public void setZipcode(String zipcode)
try
if((zipcode==null) ||(zipcode.length()<=0 && zipcode.length() > 10))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Zipcode");
else
this.zipcode = zipcode;
catch(Exception e)
e.printStackTrace();
public void setTelephone(String telephone)
try
if((telephone==null) || (telephone.length() <= 0 && telephone.length()> 7))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Telephone");
else
this.telephone = telephone;
catch(Exception e)
e.printStackTrace();
public void setFax(String fax)
try
if((fax == null) ||(fax.length()<=0 && fax.length() > 7))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Fax");
else
this.fax = fax;
catch(Exception e)
e.printStackTrace();
/* Get method */
public String getVendorNumber()
return vendorNumber;
public String getVendorName()
return vendorName;
public String getAddress()
return address;
public String getCity()
return city;
public String getState()
return state;
public String getZipcode()
return zipcode;
public String getTelephone()
return telephone;
public String getFax()
return fax;
/* end of get method*/
} // end of class
2) the 2nd error is in the save button method , everytme i try 2 save the inserted record it gives me an error.
in case u need my mainpage.java, here it is
code:--------------------------------------------------------------------------------
package mainpage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JPanel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.sql.ResultSet;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.OracleResultSet;
public class MainPage extends JFrame implements ActionListener
public static String title = "Warehouse Management System";
JFrame frame = new JFrame();
JMenuBar menuBar = new JMenuBar();
JMenu viewMenu = new JMenu("VIEW");
JMenuItem vendorItem = new JMenuItem("Vendor Master");
JMenuItem custItem= new JMenuItem("Customer Master");
JMenuItem salesrepItem= new JMenuItem("Sales Rep Master");
JMenuItem itemmastItem= new JMenuItem("Item Master");
JMenuItem orderItem= new JMenuItem("Order Master");
JMenuItem invoiceItem = new JMenuItem("Invoice Master");
JMenuItem payItem= new JMenuItem("Payment Master");
JMenu transactionMenu = new JMenu("EDIT");
JMenuItem veneditItem = new JMenuItem("Vendor");
JMenuItem custeditItem = new JMenuItem("Customer");
JMenuItem saleItem = new JMenuItem("Rep Information");
JMenuItem itmeditItem= new JMenuItem("Item");
JMenuItem ordeditItem= new JMenuItem("Order");
JMenuItem inveditItem = new JMenuItem("Invoice");
JMenuItem payeditItem = new JMenuItem("Payment");
JMenu exitMenu = new JMenu("EXIT

2 parts to this
Limit characters in jtextfield using a custom document
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#customdocument
Specify a custom editor (jtextfield) for jtable (or column)
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#validtext

Similar Messages

  • Jintegra problem - accessing Matlab from Java??

    Hi:
    Sorry if this post doesn't belong here!!
    I am accessing Matlab from JAVA using JIntegra for COM. I tried running the example in their website.
    (http://j-integra.intrinsyc.com/support/com/doc/other_examples/Matlab.htm)
    I have also posted the example below. I am using their trial version and have included all the jars as said. I get the an unexpected output (all zero's) for reading a variable in the matlab workspace. I don't understand why I get this. Can anyone let me know if this runs for you??
    Thanks
    Pavan
    Example code from Jintegra website:
    public class MatlabExample {
    public static void main(java.lang.String[] args) throws Exception {
    try {
    // DCOM authentication: Make sure NT Domain, NT User, NT Password are valid credentials.
    // Uncomment this line if MatlabExample.java remotely accesses MATLAB :
    // com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD");
    // Create the MATLAB object
    // Specify host name or IP address of MATLAB machine as parameter if
    // MatlabExample.java remotely accesses MATLAB.
    // mlapp.MLApp mlApp = new mlapp.MLApp("123.456.789.0");
    mlapp.MLApp mlApp = new mlapp.MLApp();
    String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]");
    System.out.println("Execute result is " + result);
    double mreal[][] = new double[2][4];
    double mimage[] = new double[0];
    mlApp.getFullMatrix("a", "base", new Object[]{mreal}, new Object[]{mimage});
    for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 4; j++) {
    System.out.println(mreal[i][j]);
    } finally {
    com.linar.jintegra.Cleaner.releaseAll();
    }

    ......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
    Maybe you could post the relevant JSP code too?
    Hello again,
    Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
    Here is the JSP code
    <%@page import="dev.*" %>
    <%@page session="true" language="java" import="java.io.*" %>
    <jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
    <html>
    <head>
    <title>Round Detail</title>
    <body>
      <table width="530" bordercolor="#000000" valign="top">
        <tr>
              <td align="left"  width="19%">Game ID<%=wagerhist.string_gameID%></td>
              <td align="left"  width="30%">  </td>
              <td align="left"  width="20%">card1</td>
              <td align="left"  width="31%">  </td>
            </tr>
      </table>
    </body>
    </html>

  • Accessing tables from different schema in CDS and AMDP

    Hi All,
    We are working on a HANA system which has several schema replicated from SAP R/3/Non SAP systems. We have BW 7.4 SP9 deployed on the same system and accessing the HANA views using latest BW virtual objects such as Open ODS , Composite providers etc.
    We are also using the BW system for few ABAP based data processing developments. We are currently accessing HANA views in ABAP programs by creating dictionary views based on external HANA views.
    We would like to however use recent possibilities of CDS and AMDP for better life cycle management of ABAP based solutions. The open SAP course on this subject was of very good help. Thanks a lot "open SAP team" for that. I would however have few open questions,
    As I understand AMDP gives us full flexibility of writing sql procedures within ABAP development environment, but can we access tables from different schema into AMDP code. If yes, then sample code would help.
    If the answer of first question is yes, then how do we manage transports between development and production systems where the schema names would be different. Currently in open HANA developments, such transport is manged using Schema mapping.
    Can I also use different schema tables in CDS views.
    We are updating few tables in ABAP dictionary after applying processing logic in ABAP program as detailed in step 1. With the new approach using AMDP, can we directly update database schema tables which will give us an optimization advantage.
    New ABAP HANA program interfaces are quite promising and we would like to use them to optimize many data intensive applications.
    Thanks & Regards,
    Anil

    Hi Anil,
    I can only answer 1. and 2. (and would be interested into 3. as well):
    1.
    Yes you can access tables from a different schema and also HANA views. In this case no 'using' is needed.
    Examples:
        RESULT = SELECT
        FROM
              "SAP_ECC"."T441V" AS t,
              "_SYS_BIC"."tmp.package/AFPO" AS a.
        WHERE ...
    2. In this case, if you need schema mapping: You could use HANA (projection) views which just forward to a different schema, also see example.
    Best regards,
    Christoph

  • Accessing SAP from JAVA

    Hi Friends,
       I've a requiremnet to create SO where data will be provided in JAVA screens. Is there any way to access SAP from java as we can do this through VB using API methods.
    Regards,
    Anupam

    see these links
    [link1|http://www.sapdevelopment.co.uk/java/jco/jcohome.htm]
    [link2|http://searchsap.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid21_cid417095,00.html]
    [link3|http://www.experts-exchange.com/Database/Software/ERP/SAP_ERP/Q_20693539.html]
    Regards,
    SAPient

  • How to View Tables from java side from NWDS/NWDI?

    HI All,
    I want to view the following tables from java side
    CRM_ISA_ADDRESS
    CRM_ISA_BASKETS
    CRM_ISA_BUSPARTNER
    CRM_ISA_EXTCONFIG
    CRM_ISA_EXTDATHEAD
    CRM_ISA_EXTDATITEM
    CRM_ISA_ITEMS
    CRM_ISA_OBJECTID
    CRM_ISA_SHIPTOS
    CRM_ISA_TEXTS
    How can I view them using NWDS/NWDI?
    Which DC has this tables?
    Could you please help me with the procedure to view them?
    Thanks and Regards,
    Gauri

    Hi All,
    crm/isa/isacoreddic and crm/isa/shopddic in SAP-CRMDIC are having these tables.
    Thanks and Regards,
    Gauri

  • [JDBC][ODBC] How to compact access database from Java ?

    Hello,
    I'm developping a java applcation wich is connected to an MS Access file database.
    For now, I don'y compact it but it would be better.
    So How can I compact an access database from Java ?
    thanks :)

    Hi ypiel,
    Try this:
    1) Download JETCOMP.exe (freeware from Microsoft);
    2) Put the following code in your app (assuming your database file name is: "DB.mdb"):
    try {
    File current = new File("DB.mdb");
    File backup = new File("BACKUP.mdb");
    if (current.renameTo(backup)) {
    Runtime.getRuntime().exec("jetcomp -src:BACKUP.mdb -dest:DB.mdb");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    Best regards,
    YT.

  • How to Create adf table from java bean

    Hi,
    How to Create adf table from java class (Not from ADF BC).
    Thanks
    Satya

    @vlsn -- you have to follow what shay said.
    Do the following in Model layer ::
    create a table property java class with your columns setters and getters like :
    *public class gridProps {*
    private int sno;
    private String orderNum;
    *public void setSno(int sno) {*
    this.sno = sno;
    *public int getSno() {*
    return sno;
    *public void setOrderNum(String orderNum) {*
    this.orderNum = orderNum;
    *public String getOrderNum() {*
    return orderNum;
    Create another table java class which will populate the values to your column values and return the collection :
    *public class gridPopulate {*
    private  List<gridProps> gridValues ;
    *public List<gridProps> setToGrid(ArrayList<ArrayList> valuesToSet) {*
    *if (valuesToSet == null) {*
    return gridValues;
    gridValues = new ArrayList<gridProps>();
    if(btnValue.equals("completeBtn"))
    return gridValues;
    for(ArrayList<String> tempArr:valuesToSet)
    gridProps gp = new gridProps();
    gp.setSno(Integer.valueOf(tempArr.get(0)));
    gp.setOrderNum(tempArr.get(1));
    return gridValues;
    Right click gridPopulate class and create this as data control.This class will be seen in Data control list.Under this data control,Drag the grid property collection(created earlier) to your page.Then execute your binding(gridPopulate) according to your logic.
    Thanks.(My jdev version 11.1.1.5.0)

  • Calling MS Access queries from Java

    Anyone have any idea if it's possible to call MS Access queries from Java? I have a client who is insistent on keeping MS Access for their database, and it'd be nice if I didn't have to receate all their queries in Java.
    I've successfully connected to and queried the Access MDB, but I need to know if it's even possible to execute the stored MS Access queries they have setup in the database.
    Thanks!

    See reply 6 in the following....
    http://forum.java.sun.com/thread.jspa?forumID=48&threadID=203818

  • How to trigger tree table from java code

    Trying to trigger tree table from java code, using :
    AdfFacesContext.getCurrentInstance().addPartialTarget(treeTableComponent);
    But its not working. Am i using the correct approach?

    Sorry for the incomplete information,
    I have a tree table in a region and that region i am including inside a jspx file. In the region i have one popup and based on the input taken from the popup i want to trigger the table to show the data.
    For that i am trying :
    FacesContext context = FacesContext.getCurrentInstance();
    UIComponent component = findComponent( context.getViewRoot(),"treeTableID");
    if(component != null){
    AdfFacesContext.getCurrentInstance().addPartialTarget(component);
    public static UIComponent findComponent(UIComponent base, String id)
    if (id.equals(base.getId()))
    return base;
    UIComponent children = null;
    UIComponent result = null;
    Iterator childrens = base.getFacetsAndChildren();
    while (childrens.hasNext() && (result == null))
    children = (UIComponent) childrens.next();
    if (id.equals(children.getId()))
    result = children;
    break;
    result = findComponent(children, id);
    if (result != null)
    break;
    return result;
    Model is getting data before i use : AdfFacesContext.getCurrentInstance().addPartialTarget(component);
    But table is not calling getData() in model to show the populated data on UI.

  • Problem while creating MS-ACCESS tables from Internal tables

    Hi All,
    I need to create Access tables from the Internal tables of an ABAP program.
    I am using RIACCESS program to create Access table and  FM TABLE_EXPORT_TO_MSACCESS for populating the records into Access table.
    Internal table name is ITAB1. I have created Z table with the same number of fields of ITAB1.
    Key fields of Ztable is MANDT and Project ID.
    I have two problems.
    1. When I am trying to create access table from RIACCESS, the Access table is not having the MANDT and Project ID as key fields. Is there any way to pass the Internal table with key fields to the selection parameter of RIACCESS?
    2. How to avoid the MANDT field from the Access table.
    Please help me.
    Thanks,
    Prabhakar

    select * from tablo@aaa;
    ERROR at line 1:
    ORA-02085: database link AAA.US.ORACLE.COM connects to HO.WORLD
    Why is it unsuccessful?
    02085, 00000, "database link %s connects to %s"
    // *Cause: a database link connected to a database with a different name.
    //  The connection is rejected.
    // *Action: create a database link with the same name as the database it
    //  connects to, or set global_names=false.
    //Maybe a configuration mismatch somewhere? What's your global_names setting?
    you should look in the trace files, enable listenner logging and tracing to get more clues about EOF error.
    Yoann.

  • Access SAP Tables from Java Program

    Hi All,
    We have a requirement to integrate attendance portal(which is done in java) with SAP.
    Our problem is how to access SAP tables from a Java program?
    Database is Sybase.
    Please suggest us a good solution.
    Thanks in advance...

    Did you go through Sap Help?
    Calling BAPIs from Java - BAPI User Guide CA-BFA) - SAP Library
    Regards,
    Philip.

  • Printing Access report from Java JButton

    hi would anyone be able to help me i need to print a MS access report from a JButton on a Java interface i have connected to the database using JDBC-ODBC and can retrieve data from the table and store it in text fields on java GUI however i have problems when it comes to printing the reports.
    Help I Need Somebody. :)

    Not possible using Java.
    I would guess that it is possible to do this using C/C++ and windows API calls. And once you figured that out then you could use JNI to call that code and that would allow you to use java.
    I can think of one other odd solution....
    1. Acquite 'AutoIt' - search for it on google
    2. Create an AutoIt script that runs Access, opens the database and runs the report.
    3. Use Runtime.exec() in Java to run AutoIt passing in the script from 2.

  • Error while accessing table from procedure but no error from anonymous plsq

    Hi All,
    I am getting a strange error while accessing a table from a different schema.
    In that concerned schema OWBSYS, i executed the following:
    grant Select on wb_rt_audit to ods;In Ods schema i executed:
    CREATE OR REPLACE SYNONYM wb_rt_audit FOR OWBSYS.wb_rt_audit;In ODS schema, when i execute:
    create or replace
    procedure pp_test as
    lv_owb_reject number := 0;
    lv_filename_1 varchar2(200):= 'asda';
    begin
        SELECT MAX(aud.rta_iid) into lv_owb_reject
                              FROM   wb_rt_audit aud
                              WHERE  aud.rta_lob_name LIKE Upper(lv_filename_1)
    end;
    /I get the error:
    Warning: execution completed with warning
    procedure Compiled.
    ORA-00942 - TABLE OR VIEW DOES NOT EXISTHowever, when i execute as an anonymous plsql the same code:
    declare
    lv_owb_reject number := 0;
    lv_filename_1 varchar2(200):= 'asda';
    begin
        SELECT MAX(aud.rta_iid) lv_owb_reject
                              FROM   wb_rt_audit aud
                              WHERE  aud.rta_lob_name LIKE Upper(lv_filename_1)
    end;
    anonymous block completedthere is no issue.
    Can someone help me understand what I might be missing:
    Edited by: Chaitanya on Feb 28, 2012 12:31 AM

    Check if have some other steps.
    SQL>conn scott1/tiger
    Connected.
    SQL>create table wb_rt_audit (rta_iid number);
    Table created.
    SQL>insert into wb_rt_audit values (100);
    1 row created.
    SQL>insert into wb_rt_audit values (200);
    1 row created.
    SQL>commit;
    Commit complete.
    SQL>grant select  on wb_rt_audit to scott2;
    Grant succeeded.
    SQL>conn scott2/tiger
    Connected.
    SQL>create synonym wb_rt_audit for scott1.wb_rt_audit;
    Synonym created.
    SQL>create or replace procedure pp_test as
        l_number number(10);
        begin
            SELECT MAX(rta_iid) into l_number
                                  FROM   wb_rt_audit;
      end pp_test;
    Procedure created.

  • Problems Accessing VARRAY from Java

    Hi,
    I am calling a stored procedure with IN parameters as VARRAYS from Java application.
    There are two schemas in the database. One main schema, say 'MAIN_SCHEMA' which contains all the table,VARRAYS,packages etc. There are public synonyms for all the database object including VARRAYS in this schema. The java application uses a connection pool created using another user say 'ADMIN'. This user has been granted priviliges for acccessing all the objects in the 'MAIN_SCHEMA'. For the VARRAYS we have created public synonyms and granted EXECUTE for ADMIN.
    However when I try to execute the stored procedure from java , I get an SQLException("invalid name pattern: ADMIN.UIDARRAY")
    I solved the problem temporarily by prefixing the main schema name to the name of the VARRAY. The sample code I have used is as below. but I am not sure if this is the correct way of doing it. I do not understand why we have to prefix the schema name if we have priviliges and public synonyms on the object.
    public void setPendingForfeituresUids(java.util.List pendingForfeituresUids) throws DAOException{
    try{
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(
    "MAIN_SCHEMA.UIDARRAY", con);
    array = new ARRAY(descriptor, con, pendingForfeituresUids.toArray());
    if(array == null){
    stmt.setNull(3,java.sql.Types.ARRAY);
    }else{
    stmt.setArray(3, array);
    }catch(SQLException e){
    closeStatement();
    releaseLobWrappers();
    throw new DAOException(e);
    Database and Drivers used
    I am using Oracle 9.2.0.1.0, Weblogic 8.1, Oracle Jdbc thin driver for 9.2 that comes bundled with weblogic (ojdbc14.jar)
    Any help on this is welcome.
    Thanks,
    Sunil

    Hi Sunil,
    I was wondering if you had any solution to the problem you listed.
    We are also facing a similar problem and is reported to oracle. Its a Bug as per oracle.
    Any help in getting this resolved is appreciated.
    Thanks,
    Sandip
    [email protected]

  • Accessing JFX from Java or find a workarround

    Hi there, I'm a new one ...
    I'm working on this project designing applications for a touch panel. I've written a little Java app that uses JNA to access the driver and grab the coordinates of touches on the panel. Works fine so far ...
    Now I'm creating an UI using Java FX. I've got the thing up and running, only experiencing minor problems due to learning JFX.
    When it comes to combining the UI with the Java classes that access the driver I'm not sure how to implement the whole thing. I know it's only possible to access Java from JFX, not the other way arround. My java classes though are the ones who should trigger the events the UI should react to.
    I think I've read something about the possiblity to use reflection to call JFX functions from Java which is one idea I could go with. (if anyone got good links ...)
    The other idea is that I implement a sort of FIFO object where my Java classes drop events and a timer in my JFX classes where I pull them out (not sure if MediaTimer is the right class to go with)
    Any suggestions, tips, etc. ? :)
    Greetings, Alex

    I think that if you create a interface in java and a class in javafx that implements that interface you can then pass that class to java. For instance:
    Java:
    public interface EventReceiver {
        public void receive(String event);
    // Then your java class that generates the events
    public class EventGenerator {
        private List<EventReceiver> receivers = new LinkedList<EventReceiver>();
        public void registerEventReceiver(EventReceiver er) {
            receiver.add(er);
        public void unregisterEventReceiver(EventReceiver er) {
            receiver.remove(er);
         *  Add code that calls EventReceiver.receive(String) method for each element in the receiver list
         *  when the panel is touched.
    }and in the JavaFX code:
    public class JavaFXEventReceiver extends EventReceiver {
        public override function receive(String event) {
            // Do UI updates...
    }A little more indepth version can be found here:
    http://www.compare-review-information.com/pure-java-code-to-call-javafx-class/
    You might run into some problems though pertaining to threading...but there are workarounds for that aswell :)
    - Emil H

Maybe you are looking for

  • Quicktime not playing movies

    I have quicktime pro and am trying to play my movies. Usually I put the dvd in and qt reads and plays the movie by default. I don't understand why this is not happening anymore - any suggestions would be most appreciated. Thank you

  • Regarding a select statement

    hi, i got a select statement in my program as shown below select * from ce4e001 where bukrs eq s_bukrs-low. check s_kndnr. check s_prctr. move-corresponding ce4e001 to v_ce4e001. append v_ce4e001. endselect. now i want to rewrite this select statemen

  • Regarding Video segmentation

    If video contain 50 frames(eg 30 sec),i want convert into 25frames(eg 15 sec) ,with  same meaning... I want to take middle of the frames  which i need,Is it possible with Labview.

  • Services performed in Service entry sheet

    hi gurus how can u enter services performed in Service entry sheet copy from po chose from service selection drag and drop manually

  • How to post or use fi upload bapis

    hi everybody,   this is giri i need some help in bapis upload report. its related to fi module, here i have given details regarding this below. in how to pass data to bapi i dont know .and this bapi containig idoc segenets like IDOC Segment - BAPIACH