NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
jinwah50
Joined: 13 Nov 2008 Posts: 2
|
Posted: Thu Nov 13, 2008 12:41 pm Post subject: GUIDs and databases |
|
|
Hi,
I want to read/write a GUID from/to a SQL Server field of the type uniqueidentifer.
I am using a PreparedStatement which has various methods such as setInt, setString etc.
How to setGUID? and then subsequently when I read it back in how do I read it?
Thanks
Jin |
|
| Back to top |
|
 |
jinwah50
Joined: 13 Nov 2008 Posts: 2
|
Posted: Thu Nov 13, 2008 3:52 pm Post subject: RE: GUIDs and databases |
|
|
The solution was to simply use setString and getString.
I am using org.safehaus.uuid.UUID as my GUID field type.
So for the write:
preparedStatement.setString(1, myObject.getUid().toString());
and the read:
result.setUid(new UUID(resultSet.getString(1)));
Just in case anybody else ever searches for this question!
Thanks
Jin |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|