开发者

Queryin SQL table with "TEXT" datatype column in java

开发者 https://www.devze.com 2023-01-07 20:19 出处:网络
i have a \"TEXT\" type column in a sql database. I queried it with开发者_Go百科 ResultSet rs=db.execSQL(query);

i have a "TEXT" type column in a sql database. I queried it with开发者_Go百科

ResultSet rs=db.execSQL(query);
String s=rs.getString("text_field");

creates and error. how should i use this text column in my java?


This looks like Java and JDBC (the standard API to uses databases with Java.

Here is a tutorial, chapter 3.2.2 shows the general solution to your problem. You have to call next() on the result set to set the pointer to the next row.

Applied to your code, this should give some progress:

ResultSet rs=db.execSQL(query);
while(rs.next()) {
   String s=rs.getString("text_field");
   // do something with s
}
0

精彩评论

暂无评论...
验证码 换一张
取 消