@Override
	public boolean saveObjectToDatabase(Connection conn) throws ProvisionException {
		java.sql.Statement stmt;
		ResultSet rs;
		try {
			conn.setAutoCommit(false);
			stmt = conn.createStatement();
			String sql;
			java.sql.PreparedStatement pstmt = null;
			if (this.getId() == 0) {
				pstmt = conn.prepareStatement ("select stt_teacher_id from st_teacher where stt_teacher_id='"
						+ teacherId + "'");
				rs = pstmt.executeQuery();
				if (rs.next()) {
					// TODO: create error json object and then return
					throw new ProvisionException(2, "User already exists");
				}
				pstmt = conn.prepareStatement("insert into st_users (stu_fname, stu_lname, stu_email , stu_password, stu_role) "
						+ " values(?, ?, ?, ?, ?)");
				pstmt.setString(1, this.fName);
				pstmt.setString(2, this.lName);
				pstmt.setString(3, this.emailId);
				pstmt.setString(4, this.password);
				pstmt.setInt(5, this.role);
				pstmt.executeUpdate();
				ResultSet keys = pstmt.getGeneratedKeys();
				keys.next();
				int id = keys.getInt(1);
				if (id != 0) {
					this.setId(id);
					java.sql.PreparedStatement pStmt = conn.prepareStatement("insert into st_teacher (stt_id, stt_teacher_id, stt_deptt) values (?, ?, ?)");
					pStmt.setInt(1, id);
					pStmt.setInt(2,  this.teacherId);
					pStmt.setInt(3, this.department);
					
					pStmt.executeUpdate();
				}
				conn.commit();
				return true;
				

			} else {
				conn.setAutoCommit(false);
				java.sql.PreparedStatement pStmt = conn.prepareStatement("select stu_id from st_users where stu_id=?");
				pStmt.setInt(1, this.getId());
				rs = pStmt.executeQuery();
				if (rs.next() == false) {
					// TODO: create error json object and then return
					throw new ProvisionException(3, "User does not exist. Invalid Id");
				}
				pStmt = conn.prepareStatement("update st_users set stu_fname=?, stu_lname=?, stu_email=?,stu_role=? where stu_id=?");
				pStmt.setString(1, this.fName);
				pStmt.setString(2, this.lName);
				pStmt.setString(3, this.emailId);
				pStmt.setInt(4, this.role);
				pStmt.setInt(5, this.getId());
				pStmt.executeUpdate();
				
				pStmt = conn.prepareStatement("update st_teacher set stt_teacher_id=?, stt_deptt=? where stt_id=?");
				pStmt.setInt(1, this.teacherId);
				pStmt.setInt(2, this.department);
				
				pStmt.setInt(3, this.getId());
				pStmt.executeUpdate();
				conn.commit();
				return true;				
			}
		
			} catch (SQLException ex) {
			ex.printStackTrace();
			try {
				conn.rollback();
				throw new ProvisionException(4, "DB Error, while working with Student DB");
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				throw new ProvisionException(4, "DB Error, Could not roll back");
			}
		}

	}