January 9, 2011 at 3:26 pm
I have a problem selecting guid data from a table using a simple resultset
Here is the code
java.sql.PreparedStatement ps = conn.prepareStatement("SELECT FORUM_ID, USER_ID FROM forum_users where id="
+ "?");
ps.setString(1, key);
rs = ps.executeQuery();
while (rs.next())
{
string forumId = rs.getString(1);
}
FORUM_ID - GUID
Can I select Guid on a simple resultset?
What java type corresponds to a GUID type?
Please a little help
January 10, 2011 at 10:23 am
Yes you can select a GUID on the sql side of things very easily. Your sql looks like it should be fine. As for the datatype of a GUID in java, I am not a java guy but I would bet it would take about 5 seconds on google to find it.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 10, 2011 at 2:12 pm
Hi. Thnx for your reply.
I've solved the problem replacing the uniqueidentifier with int and making the column "identity Column".
I've google-ed the problem, but it seams like java don't have a corresponding type of uniqueidentifier (Guid).
The only way to handle this problem is to use SQLServerResultSet or to use an alternative solution, like replacing uniqueidentifier with int 😉
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply