[Building Sakai] Updating SQL database directly

Mark J. Norton markjnorton at earthlink.net
Wed Jan 30 05:56:24 PST 2013


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 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"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20130130/111788a9/attachment.html 


More information about the sakai-dev mailing list