HELP-Resultset method: getString w/ LONGVARCHAR

Hello Everyone. When I use the getString method of a ResultSet class on a LONGVARCHAR data type, I get unexpected results. For instance, If the column contains a long text with several words (LONGVARCHAR data type), the getString method generates a string for each word in that column! Therefore, what method do I use that will store serveral words in ONE string object?

Here's a sample code which a prints out column headers and their respective data from a Access database separated by a "~" symbol. However, when the ResultSet runs into a LONGVARCHAR data type, it generates a column for each word in the column that has a long text with several words separated by a space:

import java.sql.*;

import java.io.*;

class SimpleQuery {

public static void main(String args[]) {

String url = "jdbc:odbc:Books";

Connection con;

String query =

"select * from Publishers";

Statement stmt;

try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {

System.err.print("ClassNotFoundException: ");

System.err.println(e.getMessage());

}

try {

con = DriverManager.getConnection(url,

"myLogin", "myPassword");

stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

ResultSetMetaData rsmd = rs.getMetaData();

int numberOfColumns = rsmd.getColumnCount();

for (int i = 1; i <= numberOfColumns; i++) {

if (i > 1) System.out.print("~ ");

String columnName = rsmd.getColumnName(i);

System.out.print(columnName);

}

System.out.println("");

while (rs.next()) {

for (int i = 1; i <= numberOfColumns; i++) {

if (i > 1) System.out.print("~ ");

System.out.print(strValue);

String columnValue = rs.getString(i);

System.out.print(columnValue);

}

System.out.println("");

}

stmt.close();

con.close();

} catch(SQLException ex) {

System.err.print("SQLException: ");

System.err.println(ex.getMessage());

}

}

}

[2148 byte] By [ham17151] at [2007-9-26 3:41:59]
# 1

Hello, Can anyone help me? To recap, the problem I am having is with the fact that one of the column in an Access database is of type "memo". So when I use a getString method or even the getObject method to get the string value of that column, those 2 methods end up making a column for each word in that column. For some reason, because the column data is too long, the methods create a column for each word after so many characters. It looks like if the text contains more than 255 characters, then any words that appear afterwards are seen as individual strings. Is there a work around for this? Thanks for any help.

ham17151 at 2007-6-29 12:19:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...