Java Reference
In-Depth Information
stmt . close ();
// put the data in the table
PreparedStatement ps = conn . prepareStatement (
"INSERT INTO users VALUES (?,?,?,?,?,?,?,?)" );
String line ;
while
while (( line = is . readLine ()) != null
null ) {
iif ( line . startsWith ( "#" )) {
// comment
continue
continue ;
}
StringTokenizer st =
new
new StringTokenizer ( line , ":" );
String nick = st . nextToken ();
String pass = st . nextToken ();
String full = st . nextToken ();
String email = st . nextToken ();
String city = st . nextToken ();
String prov = st . nextToken ();
String ctry = st . nextToken ();
// User u = new User(nick, pass, full, email,
// city, prov, ctry);
String privs = st . nextToken ();
int
int iprivs = 0 ;
iif ( privs . indexOf ( "A" ) != - 1 ) {
iprivs |= User . P_ADMIN ;
}
iif ( privs . indexOf ( "E" ) != - 1 ) {
iprivs |= User . P_EDIT ;
}
ps . setString ( 1 , nick );
ps . setString ( 2 , pass );
ps . setString ( 3 , full );
ps . setString ( 4 , email );
ps . setString ( 5 , city );
ps . setString ( 6 , prov );
ps . setString ( 7 , ctry );
ps . setInt ( 8 , iprivs );
ps . executeUpdate ();
}
ps . close ();
// All done with that statement
conn . close ();
// All done with that DB connection
return
return ;
// All done with this program.
Search WWH ::




Custom Search