[Building Sakai] Updating SQL database directly
Nguni Phakela
nguni52 at gmail.com
Wed Jan 30 06:10:04 PST 2013
Thank you Mark. I wasn't sure if there was another approach to this. I will
try that.
Cheers,
Nguni
On Wed, Jan 30, 2013 at 3:56 PM, Mark J. Norton
<markjnorton at earthlink.net>wrote:
> Why do this with a direct database operations? This is what the User
> service is supposed to handle. Get an instance of the
> UserDirectoryService, get a UserEdit instance for the user id. Set the EID
> and commit it.
>
> - Mark Norton
>
>
> On 1/30/2013 4:02 AM, Nguni Phakela wrote:
>
> Hi,
>
> I have the following code to update a table:
>
> conn = dataSource.getConnection();
> String updateString = "update SAKAI_USER_ID_MAP set EID = ? where USER_ID
> = ?";
> PreparedStatement updateOptions = conn.prepareStatement(updateString);
>
> System.out.println(updateOptions.toString());
>
> updateOptions.setString(1, studentNumber);
> updateOptions.setString(2, user.getId());
>
> System.out.println(updateOptions.toString());
>
> int rowsUpdated = updateOptions.executeUpdate();
>
> System.out.println("Number of rows updated: " + rowsUpdated);
>
>
> I'm getting the following output:
> com.mysql.jdbc.JDBC4PreparedStatement at 77c03963: update SAKAI_USER_ID_MAP
> set EID = ** NOT SPECIFIED ** where USER_ID = ** NOT SPECIFIED **
> com.mysql.jdbc.JDBC4PreparedStatement at 77c03963: update SAKAI_USER_ID_MAP
> set EID = 'xxxxxx' where USER_ID = 'xxxxxxxxx-d0fb-4824-aa45-f65e5ecad515'
>
> The executeUpdate() seems to not be executing, and the printout for the
> number of rows updated
> also seems to not be executing.
>
> What could I be missing?
>
> Cheers
>
> --
> Nguni Phakela
>
>
> _______________________________________________
> sakai-dev mailing listsakai-dev at collab.sakaiproject.orghttp://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>
>
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to
> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
> "unsubscribe"
>
--
Nguni Phakela
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20130130/e04fa529/attachment.html
More information about the sakai-dev
mailing list