jdbc - Searching a integer type database field through java -


I want to search the database by giving the voucher number as the criteria search criteria, but the required number is integer, so I do not Suggest the following code, some other code for it. Try

  {string sql = "item type"}, select item type as MD, by MD_, model 'model', sell_price 'sailing Price ', buy_price as' Buy Price', the date of purchase as' purchase date ',' voucher no. ' As the vouchers, vouchers as the voucher date, record_no as 'record number' From purchase "where vouch_no = ?; Ps = con.prepareStatement (SQL); ps.setstring (1, txt_vouchno_p.getText ()); Rs = ps.executeQuery (); Table_p.setModel (DbUtils.resultSetToTableModel (Rs)); } Hold (pre-SQLException) {JOptionPane.showMessageDialog (empty, "error:" + east);} hold (exception before) {JOptionPane.showMessageDialog (zero, "error:" + east);}    

Change the value of txt_vouchno_p.getText () using an int and according to your the state created accordingly:

  ps.setInt (1, Integer.parseInt (txt_vouchno_p.getText ()))) ;   

looks like a typo in your current code, but string s for the capital letter, do not be afraid, divide it into several lines, the compiler will give it a single Large enough to convert large string , then this line:

  type the item type as string sql = "item type", 'byte by 'MD_byte' as model, 'model', as 'selling price' Ry_prais, Krid_prisej 'purchase price', purchased as a "shopping on 'voucher number. Voucault as voucher, as the date of voucher, record number as 'record number'. From the purchase "where vouch_no = ?;   

should be rewritten:

  select item type as string sql =" item type " Sales as "MD", "Sale Price" as "MED BY", "MED BY", "'+', 'Purchase Price', '' + '', PurchaseDate As the date of purchase, 'voucher no.', Vouch_date as "voucher date", "+", record_no as "record number" from "+" where "+" where vouch_no =? ";    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -