so your saying something like this:
try {
MyConnection myDBcon = new MyConnection();
dbCon = (Connection)myDBcon.getCon
statement = (PreparedStatement)dbCon.p
rs = (ResultSet)statement.execu
}
catch(Exception e) {
out.println("Error retrieving data." + e + "<br><br>Query is:<br><br>" + querystring + "<br><br>");
}
String newVar = pad(acp_viewer_id, 10, true);
String newVar2 = pad(subscriber_number, 10, true);
String newVar3 = pad(creation_date, 15, true);
try {
while (rs.next()) {
viewer_id = rs.getString("viewer_id") != null ? rs.getString("viewer_id").
subscriber_number = rs.getString("subscriber_n
creation_date = rs.getString("creation_dat
out.println(+viewer_id+"\t
}
rs.close();
statement.close();
dbCon.close();
}
catch(Exception e) {
out.println("Error: " + e);
}
Main Topics
Browse All Topics





by: mrcoffee365Posted on 2008-12-23 at 08:42:55ID: 23234748
The best way to handle this is to write some methods which pad a string. You'll need to pad left or right, it looks like -- usually ids pad left, and names pad right. Date is a special case -- you should probably format your dates to match the desired 15 char date rather than simply padding left or right. If you call your method pad, then the call to it might look like this:
String newVar = pad(oracleVar, 10, true);
where 10 is the new length you want (because you don't need to pad if the length is already 10, and you'll want to substring if the input length is over 10), and true says to pad right.