Thanks for taking a look. Here's basically what I am doing. This is a
method of a bean I am using. I have determined (by testing) that the values
are still without trailing spaces once fed into the method. It seems to be
something that happens after arriving in the method and during/after writing
to the dB. The odd thing is ... that even if something funky was going on
... I presumed that my varChar dataType in SQL server would automatically
prevent this from happening.
Well, I have found a way if living with this I suppose (simply trimming
every value on the way out of the db) but I would *really* like to know the
solution if you have any thought.
Thanks in advance!
Neal
public void addError(int projId, String reporter, String type, int urgent,
String title, String notes) {
// Add a new error to the database
try{
pSql = "INSERT INTO tbl_qa_errors (project_id, reported_by,
error_type, is_urgent, error_title, notes values (?,?,?,?,?,?)";
PreparedStatement pst = cn.prepareStatement(pSql);
pst.setInt(1,projId);
pst.setString(2,reporter.trim());
pst.setString(3,type.trim());
pst.setInt(4,urgent);
pst.setString(5,title.trim());
pst.setString(6,notes.trim());
pst.execute();
}catch (Exception
{
System.err.println(ex);
}
}
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Walt Meyer
Sent: Friday, August 25, 2000 7:11 PM
To: [EMAIL PROTECTED]
Subject: Re: [JSP-INTEREST] Values not trimming - writing to DB
Are you doing this
String string1 = somevariable;
String string2 = someothervariable;
string1.trim();
string2.trim();
and then using string1 and string2 in the prepared statement?
Walt
-----Original Message-----
From: Neal Cabage [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 25, 2000 8:13 AM
To: [EMAIL PROTECTED]
Subject: Values not trimming - writing to DB
I am setting values into my dB (SQL server) and using a prepared statement
to do so. I simply put in the values from my form and that should be that.
The values (once in the dB) however have a ton of empty spaces at the end of
the values however, up to the full length of the dB field.
Here's the source of my confusion:
1. The dataTypes in SQLServer are set to VarChar, not char.
2. I am using the .trim() method on each string prior to setting it in the
prepared statement
3. I just rolled the code that does the dB insert into a bean - but the
identical code within my JSP didn't give me thatproblem.
Does anyone why this would be or how I could get around it?
Thanks.
Neal
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets