I am using the following code to read data from a csv file. Can someone help me when I have a numeric with leading zero's in my csv file
in the output the leading zero's are automatically being removed. I want to keep the leading zero's. e.g. I have a following csv-file:
Now when I read the file in the second row the data 0001234 comes out to be 1234, but I need it to be as 0001234 and don't want any data
to be modified. May be Microsoft Driver doing something. Any work arrounds. Following is a code snippet>
Any help or workarround is really appreciated. Thanks
in the output the leading zero's are automatically being removed. I want to keep the leading zero's. e.g. I have a following csv-file:
Code:
1234,Mike,1235 XYZ,1
0001234,,,2
12340000,Test,1235 XYZ,3
to be modified. May be Microsoft Driver doing something. Any work arrounds. Following is a code snippet>
Code:
c = DriverManager.getConnection("jdbc:odbc:;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=.;Extensions=csv,txn");
stmt = c.createStatement();
String sql = "select * from " + filelocation;
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while(rs.next())
{
String Number = rs.getString("Number");
String Name = rs.getString("Name");
String Address = rs.getString("Addr");
String Count = rs.getString("Count");
}