reset password
Author Message
Vanquish39
Posts: 134
Posted 18:22 May 17, 2011 |

Professor, for hw4, I'm going to have 3 pre-defined users in the database. 


Should I manually insert them into the database via mysql or use preparedStatements in the init() method? 

If I use it in the init method, every time the server is restarted, the database tables become empty. 

cysun
Posts: 2935
Posted 18:59 May 17, 2011 |

You can put the INSERT statements in hw4.sql.

Vanquish39 wrote:
....  or use preparedStatements in the init() method? 

If I use it in the init method, every time the server is restarted, the database tables become empty. 

Data in the database won't be affected by server restart. The problem is that every time you restart the server or reload the application, init() will be executed and it will try to do the insert again even though the table is already populated.

Vanquish39
Posts: 134
Posted 20:38 May 17, 2011 |

I thought of that too.  I added a 'delete from users' inside the init, but the hw4.sql inserts seem better.

Also, cysun and cs320stu31 should also be in the database right?

 

Thanks

Last edited by Vanquish39 at 20:42 May 17, 2011.
cysun
Posts: 2935
Posted 23:06 May 17, 2011 |
Vanquish39 wrote:

...

Also, cysun and cs320stu31 should also be in the database right?

Yes.