java - Microsoft][ODBC Driver Manager] Invalid string or buffer length -


package project;  import java.awt.font; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jcombobox; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jtextfield; import java.sql.*; import javax.swing.joptionpane;   public class newadmition implements actionlistener {     private jframe f;     private jlabel lb,lb1,lb2,lb3,lb4,lb5,lb6,lb7;     private jbutton bt,bt2,bt3;     private jtextfield tx1,tx3,tx4,tx5,tx6;     private jcombobox cb,cb2;     private connection con;      string s[] ={"6","7","8","9","10","11","12"};     string g[]={"jalandhar","ludhiana","chandigarh","patiala"};      public newadmition()     {         f=new jframe("new admition");         lb=new jlabel("enter required information");         lb.setfont(new font("serif",font.plain, 18));         lb1=new jlabel("name");         lb2=new jlabel("class");         lb3=new jlabel("id");         lb4=new jlabel("city");         lb5=new jlabel("address");         lb6=new jlabel("contact");         lb7=new jlabel("marks");         tx1=new jtextfield();         tx4=new jtextfield();         tx5=new jtextfield();         tx6=new jtextfield();         cb=new jcombobox(s);         tx3=new jtextfield();         cb2=new jcombobox(g);         bt2=new jbutton("submit");         bt3=new jbutton("back");         bt2.addactionlistener(this);         bt3.addactionlistener(this);     }     public void launch()     {         f.setlayout(null);         f.setsize(420,500);         f.setlocation(400,100);         f.add(lb);         f.add(lb1);         f.add(lb2);         f.add(lb3);         f.add(lb4);         f.add(lb5);         f.add(lb6);         f.add(lb7);         f.add(tx1);         f.add(cb);         f.add(tx3);         f.add(tx4);         f.add(tx5);         f.add(tx6);         f.add(cb2);         f.add(bt2);         f.add(bt3);         lb.setbounds(10,10,300,40);         lb1.setbounds(40,80,100,25);         tx1.setbounds(120,80,200,25);         lb2.setbounds(40,130,100,25);         cb.setbounds(120,130,200,25);         lb3.setbounds(40,180,100,25);         tx3.setbounds(120,180,200,25);         lb4.setbounds(40,230,100,25);         cb2.setbounds(120,230,200,25);         lb5.setbounds(40,280,100,25);         tx4.setbounds(120,280,200,25);         lb6.setbounds(40,330,100,25);         tx5.setbounds(120,330,200,25);         lb7.setbounds(40,380,100,25);         tx6.setbounds(120,380,200,25);         bt2.setbounds(300,420,80,25);         bt3.setbounds(10,420,80,25);         f.setvisible(true);     }      public void actionperformed(actionevent e)     {         if(e.getsource().equals(bt3))         {             f.dispose();         }         if(e.getsource().equals(bt2))         {             try             {                  class.forname("sun.jdbc.odbc.jdbcodbcdriver");                  con =drivermanager.getconnection("jdbc:odbc:project","sa","123456");                  preparedstatement stmt= con.preparestatement("insert classrecords (name,id,city,contact,class,marks,address) values(?,?,?,?,?,?,?)");                  stmt.setstring(1,tx1.gettext());                  stmt.setint(2,integer.parseint(tx3.gettext()));                  stmt.setstring(3,cb2.getselecteditem().tostring());                  stmt.setint(4,integer.parseint(tx5.gettext()));                  stmt.setstring(5,cb.getselecteditem().tostring());                  stmt.setint(6,integer.parseint(tx6.gettext()));                  stmt.setstring(7,tx4.gettext());                  stmt.executeupdate();                  joptionpane.showconfirmdialog(f,"data saved");             }             catch(exception ex)             {                 joptionpane.showconfirmdialog(f,"this id exist");             }         }     } } 

this produce exception ( microsoft][odbc driver manager] invalid string or buffer length) working earlier until re installed java...after throw exception have checked whole program there isn't wrong @ in coding,plz me solving out this.

i comment don't have enough reputation.

if change in environment, without changing code, , error, might encoding mismatch.

i had same issue when switching 32 bit machine 4d driver v11 64 bit machine 4d driver v13. printing out resultset revealed data not decoded correctly. updating v14 on 64bit machine solved it.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -