Problem with entering data
I have a windows Xp system with Microsoft SQL Server 2005 setup and using java 1.6
I'm using the JDBC-ODBC Bridge and also setup the DSN and that works fine.
The following code worked fine a few days back but now every time I enter a row of data and if the data type of a variable isvarchar orchar it enters the text followed by spaces.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Mydata","myusername","mypassword");
PreparedStatement stat2=con.prepareStatement("insert into Login(vUserName,vPassword,vAddress,age) values(?,?,?,?)");
stat2.setString(1,textName.getText());
stat2.setString(2,textPass.getText());
stat2.setString(3,textAddress.getText());
stat2.setInt(4,Integer.parseInt(textAge.getText()));
stat2.executeUpdate();
JOptionPane.showMessageDialog(frame,new String("Your details have been registered"));
If I enter a name such asJohn in the textName field, when it updates the database, it adds spaces afterJohn upto the max capacity. (The vUserName in the database is a VARCHAR(25) ).
Could this be a problem with the odbc driver or the jdbc driver?
P.S The username and password are bogus here.
Thanks in advance
Message was edited by:
ArcherKing

